@gtkx/runtime 1.2.1 → 1.3.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.
Files changed (91) hide show
  1. package/README.md +2 -1
  2. package/dist/arg.d.ts +6 -1
  3. package/dist/arg.d.ts.map +1 -1
  4. package/dist/arg.js +2 -1
  5. package/dist/arg.js.map +1 -1
  6. package/dist/closure.d.ts.map +1 -1
  7. package/dist/closure.js +2 -11
  8. package/dist/closure.js.map +1 -1
  9. package/dist/descriptors.d.ts +21 -3
  10. package/dist/descriptors.d.ts.map +1 -1
  11. package/dist/descriptors.js +50 -21
  12. package/dist/descriptors.js.map +1 -1
  13. package/dist/fn.d.ts +2 -0
  14. package/dist/fn.d.ts.map +1 -1
  15. package/dist/fn.js +50 -10
  16. package/dist/fn.js.map +1 -1
  17. package/dist/index.d.ts +11 -5
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +10 -4
  20. package/dist/index.js.map +1 -1
  21. package/dist/mixin.d.ts +2 -1
  22. package/dist/mixin.d.ts.map +1 -1
  23. package/dist/mixin.js +1 -1
  24. package/dist/mixin.js.map +1 -1
  25. package/dist/native-value.d.ts +9 -3
  26. package/dist/native-value.d.ts.map +1 -1
  27. package/dist/native-value.js +86 -9
  28. package/dist/native-value.js.map +1 -1
  29. package/dist/object.d.ts +14 -6
  30. package/dist/object.d.ts.map +1 -1
  31. package/dist/object.js +21 -10
  32. package/dist/object.js.map +1 -1
  33. package/dist/param-spec.d.ts +31 -1
  34. package/dist/param-spec.d.ts.map +1 -1
  35. package/dist/param-spec.js +66 -5
  36. package/dist/param-spec.js.map +1 -1
  37. package/dist/promisify.d.ts +13 -1
  38. package/dist/promisify.d.ts.map +1 -1
  39. package/dist/promisify.js +14 -1
  40. package/dist/promisify.js.map +1 -1
  41. package/dist/properties.d.ts +28 -1
  42. package/dist/properties.d.ts.map +1 -1
  43. package/dist/properties.js +139 -8
  44. package/dist/properties.js.map +1 -1
  45. package/dist/regex.d.ts +25 -0
  46. package/dist/regex.d.ts.map +1 -0
  47. package/dist/regex.js +59 -0
  48. package/dist/regex.js.map +1 -0
  49. package/dist/register-class.d.ts +154 -11
  50. package/dist/register-class.d.ts.map +1 -1
  51. package/dist/register-class.js +157 -19
  52. package/dist/register-class.js.map +1 -1
  53. package/dist/registry.d.ts +48 -4
  54. package/dist/registry.d.ts.map +1 -1
  55. package/dist/registry.js +147 -3
  56. package/dist/registry.js.map +1 -1
  57. package/dist/signal.d.ts +8 -1
  58. package/dist/signal.d.ts.map +1 -1
  59. package/dist/signal.js +41 -3
  60. package/dist/signal.js.map +1 -1
  61. package/dist/type.d.ts +2 -1
  62. package/dist/type.d.ts.map +1 -1
  63. package/dist/type.js +5 -1
  64. package/dist/type.js.map +1 -1
  65. package/dist/value.d.ts +48 -4
  66. package/dist/value.d.ts.map +1 -1
  67. package/dist/value.js +172 -16
  68. package/dist/value.js.map +1 -1
  69. package/dist/variant.d.ts +75 -26
  70. package/dist/variant.d.ts.map +1 -1
  71. package/dist/variant.js +44 -29
  72. package/dist/variant.js.map +1 -1
  73. package/package.json +4 -4
  74. package/src/arg.ts +6 -1
  75. package/src/closure.ts +2 -14
  76. package/src/descriptors.ts +74 -21
  77. package/src/fn.ts +73 -17
  78. package/src/index.ts +31 -4
  79. package/src/mixin.ts +1 -1
  80. package/src/native-value.ts +146 -14
  81. package/src/object.ts +23 -11
  82. package/src/param-spec.ts +94 -8
  83. package/src/promisify.ts +27 -1
  84. package/src/properties.ts +184 -5
  85. package/src/regex.ts +92 -0
  86. package/src/register-class.ts +446 -38
  87. package/src/registry.ts +219 -4
  88. package/src/signal.ts +77 -0
  89. package/src/type.ts +7 -0
  90. package/src/value.ts +268 -14
  91. package/src/variant.ts +184 -53
@@ -1 +1 @@
1
- {"version":3,"file":"register-class.js","sourceRoot":"","sources":["../src/register-class.ts"],"names":[],"mappings":"AACA,OAAO,EACH,aAAa,IAAI,mBAAmB,GAIvC,MAAM,cAAc,CAAC;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Interface as NativeRegisterClassInterface,\n type RegisterClassOptions as NativeRegisterClassOptions,\n type RegisterClassVfunc as NativeRegisterClassVfunc,\n} from \"@gtkx/native\";\nimport { type AnyClass, getParentClass, walkClassChain } from \"@gtkx/utils\";\nimport { wrapCallback } from \"./callback.js\";\nimport { insertMixinLayer } from \"./mixin.js\";\nimport {\n buildPropertyDispatch,\n GET_PROPERTY_VFUNC,\n makeGetProperty,\n makeSetProperty,\n type PropertyDispatch,\n type PropertySpec,\n SET_PROPERTY_VFUNC,\n toNativeProperties,\n} from \"./properties.js\";\nimport {\n getClassType,\n getInterfaceMixin,\n markDerivedClass,\n registerClassType,\n type VfuncDescriptor,\n} from \"./registry.js\";\nimport { TYPE_INTERFACE, TYPE_INVALID, typeFundamental, typeInterfaces, typeIsA } from \"./type.js\";\nimport { findClassVfuncDescriptor, findInterfaceVfuncDescriptor } from \"./vfunc.js\";\n\n/**\n * A generated interface value, such as `Gio.ListModel`, in the form {@link registerClass} takes it.\n * `__impl__` exists only in the type system: it carries the interface's `Impl` type, of which a class\n * has to match every member it declares itself, which rejects a class value and a member whose\n * signature does not fit the slot it fills. Leaving a slot to the interface is not rejected,\n * because `registerClass` does not reject it either: every member of an `Impl` type is optional,\n * and the `Partial` holds that open whatever the type declares. The `object` beside it keeps\n * TypeScript from also demanding one member in common. An interface that introspection describes\n * no vtable for carries `unknown`, since it has no slot a class could fill.\n */\ntype Interface<TImpl> = AnyClass & {\n /** Type-level slot holding the interface's `Impl` type; no value ever carries it. */\n __impl__: (impl: Partial<TImpl> & object) => void;\n};\n\n/**\n * One key of `RegisterClassOptions.properties` with every underscore turned into the dash a canonical\n * GObject property name separates its words with.\n */\ntype Dashed<TName extends string> = TName extends `${infer THead}_${infer TTail}`\n ? Dashed<`${THead}-${TTail}`>\n : TName;\n\n/**\n * One dashed key in the camelCase spelling the accessors {@link registerClass} installs carry, which is\n * the spelling the hooks that address a property by name take.\n */\ntype Camelized<TName extends string> = TName extends `${infer THead}-${infer TTail}`\n ? `${THead}${Capitalize<Camelized<TTail>>}`\n : TName;\n\n/**\n * The names a registered class carries in its property map: every key of\n * `RegisterClassOptions.properties` in camelCase, whichever spelling it was written in.\n * A `properties` object given a type of its own rather than left to inference has `string` for its key\n * type and names nothing, because a name only known as `string` addresses no member in particular.\n */\ntype InstalledNames<TProperties> = string extends keyof TProperties\n ? never\n : Camelized<Dashed<keyof TProperties & string>>;\n\n/**\n * An instance of a registered class: everything the class itself declares, plus the property map the\n * hooks that address a property by name, such as `useProperty` from `@gtkx/react`, read the installed\n * names off. Each name is typed with the value type the class declares for the member of that name,\n * so a property the class does not `declare` contributes nothing.\n */\ntype RegisteredInstance<TInstance, TProperties> = TInstance & {\n /** Type-level map from installed property name to value type; no value ever carries it. */\n __properties__: Pick<TInstance, InstalledNames<TProperties> & keyof TInstance>;\n};\n\n/**\n * The construct signature and prototype a registered class carries, both giving\n * {@link RegisteredInstance}. The signature stays abstract for as long as the class itself is, so\n * registering an abstract base leaves it as impossible to construct as it was.\n */\ntype RegisteredConstructor<TClass, TArgs extends unknown[], TInstance> = {\n /** Object the class's instances inherit from. */\n prototype: TInstance;\n} & (TClass extends new (...args: never) => unknown\n ? new (...args: TArgs) => TInstance\n : abstract new (...args: TArgs) => TInstance);\n\n/**\n * The class {@link registerClass} hands back: the same class, with the same statics, whose instances\n * carry the properties `RegisterClassOptions.properties` installed. Binding the call to a name, rather\n * than discarding it, is what carries those names into the type system.\n */\ntype RegisteredClass<TClass extends AnyClass, TProperties> =\n TClass extends abstract new (...args: infer TArgs) => infer TInstance\n ? Omit<TClass, \"prototype\"> & RegisteredConstructor<TClass, TArgs, RegisteredInstance<TInstance, TProperties>>\n : never;\n\n/** What {@link registerClass} adds to the new GType beyond the vtable slots it discovers on the class. */\ntype RegisterClassOptions<TInstance extends object, TProperties extends Record<string, PropertySpec>> = {\n /** Name to register the new GType under, defaulting to the class's own name. */\n typeName?: string;\n /**\n * Interfaces the new type implements on top of the ones it inherits, given as the interface values\n * themselves, such as `Gio.ListModel`. Their vtable slots are filled from the `vfunc`-prefixed methods on\n * the class's prototype chain, each of which has to match the interface's `Impl` type, such as\n * `Gio.ListModelImpl`.\n */\n implements?: Interface<TInstance>[];\n /**\n * Properties to install on the new type, keyed by the name JavaScript addresses each one by and\n * valued with the `GObject.ParamSpec` describing it. A key is read in camelCase however it is\n * written, so `dewPoint`, `dew_point` and `dew-point` all name the same member, and the ParamSpec\n * has to carry the canonical spelling of that name, `dew-point`, or registration throws: the\n * ParamSpec's name is the one GObject emits `notify` with, and a name the key does not spell\n * reaches nothing that listens for it. Every property gains prototype accessors, one for the key\n * as written, one for it with dashes turned into underscores and one for it in camelCase, each\n * unless the class already defines that name. They serve the value from storage of their own on\n * the instance, which is also what the type's `get_property` and `set_property` slots read and\n * write, so a value set from JavaScript, from `g_object_set_property` and at construction all\n * land in the same place.\n *\n * A write the ParamSpec would refuse throws rather than reaching GObject, which reports such a\n * write as a GLib critical and drops it: a `TypeError` for a read-only or construct-only\n * property and for a value of a type the property cannot hold, and a `RangeError` for a value\n * the ParamSpec rejects. The same checks run over a value handed to the constructor, where\n * a construct-only property is the one that is writable. An accepted write emits one `notify`,\n * which a `freeze_notify` batch collects; a write of the value the property already holds is\n * dropped and emits none.\n *\n * `null` and `undefined` both mean NULL, and mean it only where the ParamSpec's own type holds\n * NULL, which is a string, string-array, boxed, object, interface, param, variant or pointer\n * property. Such a property holds the `null` either spelling wrote, so the member, the type's\n * `get_property` slot and `g_object_get_property` serve the same thing, and writing the other\n * spelling over it emits no `notify`. Every other property, so every integer, floating-point,\n * boolean, enum, flags and GType one, refuses both with the same `TypeError` it refuses a\n * string with, and keeps the value it already holds. It refuses them for what it holds rather\n * than for its range, whatever that range is: the type is checked before the range, so a\n * `gint` whose range excludes 0 answers a nullish with that same `TypeError` and never with\n * the `RangeError` that names the value GObject would put in its place. The one place\n * `undefined` means something else is the constructor, which reads it as the property not\n * being given at all and leaves it at the ParamSpec's default, so a property is never handed a\n * value it cannot serve back.\n *\n * A floating-point property takes every JavaScript number, `NaN` and both infinities\n * included, and its ParamSpec alone rules on which of them the range admits: a `gdouble`\n * bounded by `-Infinity` and `Infinity` holds either infinity, and a magnitude a bounded\n * one excludes, like any `NaN`, comes back as the `RangeError` that names what GObject\n * would put in its place rather than as the `TypeError` a type the property cannot hold\n * earns. A `gfloat` property holds what GObject narrows the double to, so it serves `0.1`\n * back as `0.10000000149011612` and a finite magnitude no `gfloat` reaches as an infinity,\n * which the range then rules on in turn. That narrowing belongs to the property alone: the\n * same magnitude written to a `gfloat` through a generated binding, a signal argument or a\n * closure return is refused outright rather than narrowed.\n *\n * A generated property of a wrapped type answers a nullish differently, and the two halves of\n * the API disagree here: that property marshals what it is written through its descriptor\n * rather than through the checks above, so `new Gtk.Label({ widthRequest: null })` and a later\n * write of `null` to that member both land 0, where a `gint` installed here refuses both.\n *\n * A class that defines the camelCase member itself owns the property: its own accessor decides\n * what a write means, the other spellings forward to it, and the type's property slots read\n * and write it rather than the generated storage.\n */\n properties?: TProperties;\n};\n\n/** {@link RegisterClassOptions} with the widest instance and property types {@link registerClass} accepts. */\ntype AnyRegisterClassOptions = RegisterClassOptions<object, Record<string, PropertySpec>>;\ntype VfuncFn = NativeRegisterClassVfunc[\"fn\"];\ntype DiscoveredVfunc = VfuncDescriptor & { methodName: string; fn: VfuncFn };\ntype MethodTable = Map<string, VfuncFn>;\ntype InstanceMembers = { methods: MethodTable; names: Set<string>; inheritedNames: Set<string> };\n\ntype InterfaceVfuncBinding = {\n gtype: bigint;\n vfuncs: DiscoveredVfunc[];\n};\n\ntype PropertyVfuncSource = {\n klass: AnyClass;\n methods: MethodTable;\n dispatch: PropertyDispatch;\n adoptedTypes: bigint[];\n};\n\ntype PropertyVfuncSpec = {\n methodName: string;\n isValueOut: boolean;\n makeDispatch: (dispatch: PropertyDispatch) => VfuncFn;\n};\n\ntype ArgPatch = { isCallerAllocated: true } | { isCallScoped: true };\n\nconst INSTANCE_ARG_INDEX = 0;\nconst VALUE_ARG_INDEX = 2;\nconst TEARDOWN_VFUNC_NAMES: Set<string> = new Set([\"dispose\", \"finalize\"]);\n\nconst PROPERTY_VFUNC_SPECS: PropertyVfuncSpec[] = [\n { methodName: GET_PROPERTY_VFUNC, isValueOut: true, makeDispatch: makeGetProperty },\n { methodName: SET_PROPERTY_VFUNC, isValueOut: false, makeDispatch: makeSetProperty },\n];\n\nconst PROPERTY_VFUNC_NAMES: Set<string> = new Set(PROPERTY_VFUNC_SPECS.map((spec) => spec.methodName));\n\n/**\n * Registers a subclass of a wrapper class as a new GType, wiring up any class and interface\n * virtual functions it overrides, both for the interfaces it inherits and for the ones\n * `RegisterClassOptions.implements` names.\n *\n * Throws when the class does not extend a registered wrapper class, when it has no derivable type\n * name, when an entry in `RegisterClassOptions.implements` is not a registered interface, when a\n * listed interface has a prerequisite that neither the parent type nor another listed interface meets,\n * and when an entry in `RegisterClassOptions.properties` names its `GObject.ParamSpec` something other\n * than the canonical spelling of the key it sits under.\n *\n * A slot is filled from the `vfunc`-prefixed methods on the class's prototype chain, up to but not\n * including the registered ancestor the class extends, so a method an intermediate base class\n * declares fills a slot the same way one the class itself declares does. A slot nothing on that\n * chain fills is left untouched.\n *\n * Declare every slot as a method: a class field holding a function, such as `vfuncGetNItems = () => 1`,\n * is assigned to each instance after registration and never reaches the vtable.\n *\n * An override of `vfuncConstructed` runs from inside the base constructor, before JavaScript\n * installs the subclass's field initializers and runs its constructor body, so a field still\n * reads `undefined` there and reading a `#private` field throws. Declare state the override\n * touches without an initializer, and assign private state from the constructor body after\n * `super()`. An instance a native caller creates, through `GObject.newv` or `Gtk.Builder`,\n * never runs the subclass constructor at all, so its declared fields stay uninitialized for\n * the object's whole life.\n *\n * @param klass The subclass to register.\n * @param options What the new GType gains beyond the vtable slots the class overrides.\n * @returns The same class, now registered, with every name in `options.properties` in its property map.\n */\nfunction registerClass<\n T extends AnyClass,\n TProperties extends Record<string, PropertySpec> = Record<never, PropertySpec>,\n>(klass: T, options?: RegisterClassOptions<T[\"prototype\"], TProperties>): RegisteredClass<T, TProperties>;\n\nfunction registerClass(klass: AnyClass, options: AnyRegisterClassOptions = {}): AnyClass {\n const parentType = resolveParentType(klass);\n\n if (parentType === TYPE_INVALID) {\n throw new TypeError(`registerClass: ${klass.name} must extend a registered wrapper class`);\n }\n\n const name = options.typeName ?? klass.name;\n\n if (!name) {\n throw new Error(\"registerClass: cannot derive a GType name (anonymous class with no typeName option)\");\n }\n\n const declaredTypes = resolveInterfaceTypes(klass, options.implements ?? []);\n const adoptedTypes = declaredTypes.filter((gtype) => !typeIsA(parentType, gtype));\n const properties = options.properties ?? {};\n const { methods, inheritedNames } = collectInstanceMembers(klass);\n const dispatch = buildPropertyDispatch({ klass, properties, adoptedTypes });\n\n const classVfuncs = [\n ...discoverClassVfuncs(klass, methods),\n ...propertyVfuncs({ klass, methods, dispatch, adoptedTypes }),\n ];\n\n const claimedMethodNames = new Set(classVfuncs.map((vfunc) => vfunc.methodName));\n const interfaceBindings = discoverInterfaceBindings(methods, parentType, declaredTypes, claimedMethodNames);\n const nativeOptions = toNativeOptions(classVfuncs, interfaceBindings, properties);\n const newType: bigint = nativeRegisterClass(name, parentType, nativeOptions);\n registerClassType(klass, newType);\n markDerivedClass(klass);\n applyInterfaceMixins(klass, adoptedTypes, inheritedNames);\n\n return klass;\n}\n\nfunction resolveInterfaceType(klass: AnyClass, entry: AnyClass): bigint {\n const gtype = getClassType(entry);\n\n if (typeFundamental(gtype) !== TYPE_INTERFACE) {\n const label = typeof entry === \"function\" ? entry.name : String(entry);\n\n throw new TypeError(\n `registerClass: ${klass.name} lists '${label}' in implements, which is not a registered interface`,\n );\n }\n\n return gtype;\n}\n\nfunction resolveInterfaceTypes(klass: AnyClass, entries: AnyClass[]): bigint[] {\n return [...new Set(entries.map((entry) => resolveInterfaceType(klass, entry)))];\n}\n\nfunction applyInterfaceMixins(klass: AnyClass, adoptedTypes: bigint[], inheritedNames: Set<string>): void {\n for (const gtype of adoptedTypes) {\n const mixin = getInterfaceMixin(gtype);\n\n if (mixin !== undefined) {\n insertMixinLayer(klass, mixin, inheritedNames);\n }\n }\n}\n\nfunction resolveParentType(klass: AnyClass): bigint {\n return (\n walkClassChain(getParentClass(klass), (cls) => {\n const gtype = getClassType(cls);\n\n return gtype === TYPE_INVALID ? undefined : gtype;\n }) ?? TYPE_INVALID\n );\n}\n\nfunction addOwnMember(members: InstanceMembers, proto: object, name: string, isInherited: boolean): void {\n if (name === \"constructor\") {\n return;\n }\n\n if (isInherited) {\n members.inheritedNames.add(name);\n }\n\n if (members.names.has(name)) {\n return;\n }\n\n members.names.add(name);\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n\n if (typeof descriptor?.value === \"function\") {\n members.methods.set(name, descriptor.value as VfuncFn);\n }\n}\n\nfunction addOwnMembers(members: InstanceMembers, klass: AnyClass, isInherited: boolean): void {\n const proto = (klass as { prototype?: object }).prototype;\n\n if (proto === undefined) {\n return;\n }\n\n for (const name of Object.getOwnPropertyNames(proto)) {\n addOwnMember(members, proto, name, isInherited);\n }\n}\n\nfunction collectInstanceMembers(klass: AnyClass): InstanceMembers {\n const members: InstanceMembers = { methods: new Map(), names: new Set(), inheritedNames: new Set() };\n let cls: AnyClass | null = klass;\n\n while (cls !== null && getClassType(cls) === TYPE_INVALID) {\n addOwnMembers(members, cls, cls !== klass);\n cls = getParentClass(cls);\n }\n\n return members;\n}\n\nfunction buildDiscoveredVfunc(\n fn: VfuncFn,\n methodName: string,\n resolveDescriptor: (methodName: string) => VfuncDescriptor | undefined,\n skip: Set<string> | undefined,\n): DiscoveredVfunc | undefined {\n if (skip?.has(methodName)) {\n return undefined;\n }\n\n const descriptor = resolveDescriptor(methodName);\n\n if (!descriptor) {\n return undefined;\n }\n\n const argDescriptors = slotArgDescriptors(descriptor);\n\n return {\n ...descriptor,\n methodName,\n argDescriptors,\n fn: wrapVfunc(fn, argDescriptors, descriptor),\n };\n}\n\nfunction collectDiscoveredVfuncs(\n methods: MethodTable,\n resolveDescriptor: (methodName: string) => VfuncDescriptor | undefined,\n skip?: Set<string>,\n): DiscoveredVfunc[] {\n const result: DiscoveredVfunc[] = [];\n\n for (const [methodName, fn] of methods) {\n const discovered = buildDiscoveredVfunc(fn, methodName, resolveDescriptor, skip);\n\n if (discovered) {\n result.push(discovered);\n }\n }\n\n return result;\n}\n\nfunction discoverClassVfuncs(klass: AnyClass, methods: MethodTable): DiscoveredVfunc[] {\n return collectDiscoveredVfuncs(\n methods,\n (methodName) => findClassVfuncDescriptor(klass, methodName) ?? undefined,\n PROPERTY_VFUNC_NAMES,\n );\n}\n\nfunction wrapVfunc(\n fn: VfuncFn,\n argDescriptors: NativeRegisterClassVfunc[\"argDescriptors\"],\n descriptor: VfuncDescriptor,\n): VfuncFn {\n return wrapCallback(\n fn as (...args: unknown[]) => unknown,\n { argDescriptors, returnDescriptor: descriptor.returnDescriptor },\n \"vfunc\",\n );\n}\n\nfunction discoverInterfaceBindings(\n methods: MethodTable,\n parentGtype: bigint,\n declaredTypes: bigint[],\n claimedMethodNames: Set<string>,\n): InterfaceVfuncBinding[] {\n const declared: Set<bigint> = new Set(declaredTypes);\n const gtypes: Set<bigint> = new Set([...typeInterfaces(parentGtype), ...declaredTypes]);\n const bindings: InterfaceVfuncBinding[] = [];\n\n for (const gtype of gtypes) {\n const vfuncs = discoverInterfaceVfuncs(methods, gtype, claimedMethodNames);\n\n if (vfuncs.length > 0 || declared.has(gtype)) {\n bindings.push({ gtype, vfuncs });\n }\n }\n\n return bindings;\n}\n\nfunction discoverInterfaceVfuncs(\n methods: MethodTable,\n interfaceGtype: bigint,\n claimedMethodNames: Set<string>,\n): DiscoveredVfunc[] {\n return collectDiscoveredVfuncs(\n methods,\n (methodName) => findInterfaceVfuncDescriptor(interfaceGtype, methodName),\n claimedMethodNames,\n );\n}\n\nconst hasDispatchedProperties = (dispatch: PropertyDispatch, adoptedTypes: bigint[]): boolean =>\n dispatch.accessors.length > 0 || adoptedTypes.length > 0;\n\nfunction propertyVfuncFor(\n source: PropertyVfuncSource,\n spec: PropertyVfuncSpec,\n): DiscoveredVfunc | undefined {\n const { klass, methods, dispatch, adoptedTypes } = source;\n\n const dispatched = hasDispatchedProperties(dispatch, adoptedTypes)\n ? spec.makeDispatch(dispatch)\n : undefined;\n\n const fn = methods.get(spec.methodName) ?? dispatched;\n\n return fn === undefined ? undefined : buildPropertyVfunc(klass, spec.methodName, fn, spec.isValueOut);\n}\n\nfunction propertyVfuncs(source: PropertyVfuncSource): DiscoveredVfunc[] {\n return PROPERTY_VFUNC_SPECS.map((spec) => propertyVfuncFor(source, spec)).filter(\n (vfunc) => vfunc !== undefined,\n );\n}\n\nfunction markArg(argDescriptors: Descriptor[], index: number, patch: ArgPatch): Descriptor[] {\n return argDescriptors.map((arg, at) => (at === index ? { ...arg, ...patch } : arg));\n}\n\nfunction isTeardownSlot(descriptor: VfuncDescriptor): boolean {\n return (\n TEARDOWN_VFUNC_NAMES.has(descriptor.vfuncName) &&\n descriptor.argDescriptors[INSTANCE_ARG_INDEX]?.kind === \"object\"\n );\n}\n\nfunction slotArgDescriptors(descriptor: VfuncDescriptor): Descriptor[] {\n if (!isTeardownSlot(descriptor)) {\n return descriptor.argDescriptors;\n }\n\n return markArg(descriptor.argDescriptors, INSTANCE_ARG_INDEX, { isCallScoped: true });\n}\n\nfunction buildPropertyVfunc(\n klass: AnyClass,\n methodName: string,\n fn: VfuncFn,\n isValueOut: boolean,\n): DiscoveredVfunc {\n const descriptor = findClassVfuncDescriptor(klass, methodName);\n\n if (!descriptor) {\n throw new Error(`registerClass: the parent class exposes no '${methodName}' vtable slot`);\n }\n\n const argDescriptors = isValueOut\n ? markArg(descriptor.argDescriptors, VALUE_ARG_INDEX, { isCallerAllocated: true })\n : descriptor.argDescriptors;\n\n return {\n ...descriptor,\n methodName,\n argDescriptors,\n fn: wrapVfunc(fn, argDescriptors, descriptor),\n };\n}\n\nfunction toNativeInterface(binding: InterfaceVfuncBinding): NativeRegisterClassInterface {\n const nativeInterface: NativeRegisterClassInterface = {\n type: binding.gtype,\n vfuncs: [...binding.vfuncs],\n };\n\n const vtableSize = binding.vfuncs[0]?.vtableSize;\n\n if (vtableSize !== undefined) {\n nativeInterface.vtableSize = vtableSize;\n }\n\n return nativeInterface;\n}\n\nfunction toNativeOptions(\n classVfuncs: DiscoveredVfunc[],\n interfaceBindings: InterfaceVfuncBinding[],\n properties: Record<string, PropertySpec>,\n): NativeRegisterClassOptions | undefined {\n const hasInterfaces = interfaceBindings.length > 0;\n const hasClassVfuncs = classVfuncs.length > 0;\n const hasProperties = Object.keys(properties).length > 0;\n\n if (!hasClassVfuncs && !hasInterfaces && !hasProperties) {\n return undefined;\n }\n\n const options: NativeRegisterClassOptions = {};\n\n if (hasProperties) {\n options.properties = toNativeProperties(properties);\n }\n\n if (hasClassVfuncs) {\n options.vfuncs = [...classVfuncs];\n }\n\n if (hasInterfaces) {\n options.interfaces = interfaceBindings.map((binding) => toNativeInterface(binding));\n }\n\n return options;\n}\n\nexport { type Interface, registerClass };\n"]}
1
+ {"version":3,"file":"register-class.js","sourceRoot":"","sources":["../src/register-class.ts"],"names":[],"mappings":"AACA,OAAO,EACH,aAAa,IAAI,mBAAmB,GAKvC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAiB,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,eAAe,EAGf,kBAAkB,EAClB,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EAEjB,UAAU,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,oBAAoB,EAEpB,kBAAkB,EAClB,iB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EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC;AAED,OAAO,EAAkB,aAAa,EAAqC,CAAC","sourcesContent":["import type { Descriptor } from \"@gtkx/native\";\nimport {\n registerClass as nativeRegisterClass,\n type RegisterClassInterface as NativeRegisterClassInterface,\n type RegisterClassOptions as NativeRegisterClassOptions,\n type RegisterClassSignal as NativeRegisterClassSignal,\n type RegisterClassVfunc as NativeRegisterClassVfunc,\n} from \"@gtkx/native\";\nimport { type AnyClass, getParentClass, kebabCase, walkClassChain } from \"@gtkx/utils\";\nimport { wrapCallback } from \"./callback.js\";\nimport { insertMixinLayer } from \"./mixin.js\";\nimport {\n buildPropertyDispatch,\n GET_PROPERTY_VFUNC,\n makeGetProperty,\n makeSetProperty,\n type PropertyDispatch,\n type PropertySpec,\n SET_PROPERTY_VFUNC,\n toNativeProperties,\n} from \"./properties.js\";\nimport {\n getClassStructClass,\n getClassType,\n getInterfaceMixin,\n getTypeClassHandle,\n markDerivedClass,\n registerClassType,\n type VfuncDescriptor,\n wrapHandle,\n} from \"./registry.js\";\nimport {\n connectClosureSignal,\n type DeclaredSignalTypes,\n emitDeclaredSignal,\n getSignalBaseName,\n overrideSignalClassClosure,\n type SignalHandler,\n} from \"./signal.js\";\nimport {\n TYPE_INTERFACE,\n TYPE_INVALID,\n TYPE_NONE,\n type TypedClass,\n typeFundamental,\n typeInterfaces,\n typeIsA,\n typeName,\n} from \"./type.js\";\nimport { findClassVfuncDescriptor, findInterfaceVfuncDescriptor } from \"./vfunc.js\";\n\n/**\n * A generated interface value, such as `Gio.ListModel`, in the form {@link registerClass} takes it.\n * `__impl__` exists only in the type system: it carries the interface's `Impl` type, of which a class\n * has to match every member it declares itself, which rejects a class value and a member whose\n * signature does not fit the slot it fills. Leaving a slot to the interface is not rejected,\n * because `registerClass` does not reject it either: every member of an `Impl` type is optional,\n * and the `Partial` holds that open whatever the type declares. The `object` beside it keeps\n * TypeScript from also demanding one member in common. An interface that introspection describes\n * no vtable for carries `unknown`, since it has no slot a class could fill.\n */\ntype Interface<TImpl> = AnyClass & {\n /** Type-level slot holding the interface's `Impl` type; no value ever carries it. */\n __impl__: (impl: Partial<TImpl> & object) => void;\n};\n\n/**\n * One key of `RegisterClassOptions.properties` with every underscore turned into the dash a canonical\n * GObject property name separates its words with.\n */\ntype Dashed<TName extends string> = TName extends `${infer THead}_${infer TTail}`\n ? Dashed<`${THead}-${TTail}`>\n : TName;\n\n/**\n * One dashed key in the camelCase spelling the accessors {@link registerClass} installs carry, which is\n * the spelling the hooks that address a property by name take.\n */\ntype Camelized<TName extends string> = TName extends `${infer THead}-${infer TTail}`\n ? `${THead}${Capitalize<Camelized<TTail>>}`\n : TName;\n\n/**\n * The names a registered class carries in its property map: every key of\n * `RegisterClassOptions.properties` in camelCase, whichever spelling it was written in.\n * A `properties` object given a type of its own rather than left to inference has `string` for its key\n * type and names nothing, because a name only known as `string` addresses no member in particular.\n */\ntype InstalledNames<TProperties> = string extends keyof TProperties\n ? never\n : Camelized<Dashed<keyof TProperties & string>>;\n\n/**\n * The base names the signal surface takes for the signals `RegisterClassOptions.signals` declares:\n * each name as written, plus its canonical spelling with underscores turned into dashes, which\n * GObject knows the signal by too.\n */\ntype DeclaredSignalBase<TSignals> = (keyof TSignals & string) | Dashed<keyof TSignals & string>;\n/**\n * The names `connect` and `emit` take for one of the signals `RegisterClassOptions.signals`\n * declares: each spelling of each name, plus its detailed form for a signal emitted with a\n * `::detail` suffix.\n */\ntype DeclaredSignalName<TSignals> = DeclaredSignalBase<TSignals> | `${DeclaredSignalBase<TSignals>}::${string}`;\n\n/**\n * The `connect` and `emit` signatures instances gain for the signals\n * `RegisterClassOptions.signals` declares, widening the inherited ones, which take only the names\n * introspection knows. A class declaring no signals gains nothing, since no name reaches the\n * added signatures.\n */\ntype DeclaredSignalMethods<TSignals> = {\n /**\n * Type-level map from declared signal name to handler signature, feeding the hooks that\n * address a signal by name, such as `useSignal` from `@gtkx/react`; no value ever carries it.\n */\n __signals__?: Record<DeclaredSignalBase<TSignals>, (...args: never[]) => unknown>;\n /** Connects a handler to a signal `RegisterClassOptions.signals` declared. */\n connect(\n signal: DeclaredSignalName<TSignals>,\n handler: (...args: never[]) => unknown,\n isAfter?: boolean,\n ): number;\n /** Emits a signal `RegisterClassOptions.signals` declared. */\n emit(sigName: DeclaredSignalName<TSignals>, ...args: unknown[]): unknown;\n /** Connects a handler to a signal `RegisterClassOptions.signals` declared, for `off` to take off. */\n on(sigName: DeclaredSignalName<TSignals>, callback: (...args: unknown[]) => unknown, isAfter?: boolean): unknown;\n /** Connects a handler to a signal `RegisterClassOptions.signals` declared for one emission. */\n once(sigName: DeclaredSignalName<TSignals>, callback: (...args: unknown[]) => unknown, isAfter?: boolean): unknown;\n /** Disconnects a handler `on` or `once` connected to a signal `RegisterClassOptions.signals` declared. */\n off(sigName: DeclaredSignalName<TSignals>, callback: (...args: unknown[]) => unknown): unknown;\n};\n\n/**\n * An instance of a registered class: everything the class itself declares, plus the property map the\n * hooks that address a property by name, such as `useProperty` from `@gtkx/react`, read the installed\n * names off. Each name is typed with the value type the class declares for the member of that name,\n * so a property the class does not `declare` contributes nothing.\n */\ntype RegisteredInstance<TInstance, TProperties, TSignals> = TInstance &\n DeclaredSignalMethods<TSignals> & {\n /** Type-level map from installed property name to value type; no value ever carries it. */\n __properties__: Pick<TInstance, InstalledNames<TProperties> & keyof TInstance>;\n };\n\n/**\n * The construct signature and prototype a registered class carries, both giving\n * {@link RegisteredInstance}. The signature stays abstract for as long as the class itself is, so\n * registering an abstract base leaves it as impossible to construct as it was.\n */\ntype RegisteredConstructor<TClass, TArgs extends unknown[], TInstance> = {\n /** Object the class's instances inherit from. */\n prototype: TInstance;\n} & (TClass extends new (...args: never) => unknown\n ? new (...args: TArgs) => TInstance\n : abstract new (...args: TArgs) => TInstance);\n\n/** The statics a registered class keeps from the class it was, joined with {@link RegisteredConstructor}. */\ntype RegisteredParts<TClass, TArgs extends unknown[], TInstance> = Omit<TClass, \"prototype\"> &\n RegisteredConstructor<TClass, TArgs, TInstance>;\n\n/**\n * The class {@link registerClass} hands back: the same class, with the same statics, whose instances\n * carry the properties `RegisterClassOptions.properties` installed and take the signals\n * `RegisterClassOptions.signals` declares by name. Binding the call to a name, rather than\n * discarding it, is what carries those names into the type system.\n */\ntype RegisteredClass<TClass extends AnyClass, TProperties, TSignals> =\n TClass extends abstract new (...args: infer TArgs) => infer TInstance\n ? RegisteredParts<TClass, TArgs, RegisteredInstance<TInstance, TProperties, TSignals>>\n : never;\n\n/**\n * A GType in the form `RegisterClassOptions.signals` takes one: the numeric GType itself, such as\n * `TYPE_STRING` from `@gtkx/gi/gobject`, or a class carrying one, which is any generated wrapper\n * class and any class an earlier {@link registerClass} call registered.\n */\ntype SignalGType = bigint | AnyClass<TypedClass>;\n\n/**\n * One signal `RegisterClassOptions.signals` creates on the new type, sitting under the signal's\n * name. Every part is optional: `{}` declares a signal with no arguments and no return value that\n * runs its handlers in the default `RUN_FIRST` stage.\n */\ntype SignalSpec = {\n /**\n * `GObject.SignalFlags` bit mask for the signal, defaulting to `RUN_FIRST`. `DETAILED` lets\n * handlers connect to and emissions name a `::detail` suffix.\n */\n flags?: number;\n /** GType of each argument an emission carries, defaulting to none. */\n paramTypes?: SignalGType[];\n /** GType of the value an emission returns, defaulting to none. */\n returnType?: SignalGType;\n /**\n * How the emission combines what its handlers return, limited to the two accumulators GObject\n * ships: `\"first-wins\"` stops the emission at the first handler and keeps its result, and\n * `\"true-handled\"` runs handlers until one returns `true`, which requires a boolean\n * `returnType`. Without one, every handler runs and the last result stands.\n */\n accumulator?: \"first-wins\" | \"true-handled\";\n};\n\n/** What {@link registerClass} adds to the new GType beyond the vtable slots it discovers on the class. */\ntype RegisterClassOptions<\n TInstance extends object,\n TProperties extends Record<string, PropertySpec>,\n TSignals extends Record<string, SignalSpec>,\n> = {\n /**\n * Name to register the new GType under, defaulting to the class's own name. Either way the\n * name has to be a valid GType name: at least three characters, starting with a letter or\n * underscore, the rest letters, digits, `-`, `_` or `+`. Any other name throws a `TypeError`.\n */\n typeName?: string;\n /**\n * Registers the new GType abstract, the way `G_TYPE_FLAG_ABSTRACT` marks a C type: the class\n * still serves as a parent for further registered subclasses, which instantiate as usual, but\n * constructing it directly throws, whether from JavaScript or from a native caller.\n */\n abstract?: boolean;\n /**\n * Name instances of the new type carry in CSS, applied through `gtk_widget_class_set_css_name`\n * from inside the type's `class_init`, so every instance is born with it, wherever it is\n * created from. Requires the class to extend `Gtk.Widget`; registering a non-widget with a\n * `cssName` throws.\n */\n cssName?: string;\n /**\n * Hook run once, synchronously, while `registerClass` registers the type, after its\n * `class_init` has installed the vfuncs, properties and signals declared here. It receives the\n * new type's class struct wrapped in its generated GTypeStruct wrapper, so class-level setup\n * calls such as `Gtk.WidgetClass.installAction`, `Gtk.WidgetClass.addShortcut` and\n * `Gtk.WidgetClass.setLayoutManagerType` have somewhere to land. The wrapper serves the\n * members of every struct in the parent chain on one object: a widget subclass sees\n * `Gtk.WidgetClass` and `GObject.ObjectClass` members alike, so the parameter can be declared\n * as whichever of those types the hook needs. The class struct belongs to the type system for\n * the life of the process, so keeping the wrapper around past the hook is safe, if rarely\n * useful. An exception the hook throws propagates out of `registerClass`, with the type\n * already registered: GObject offers no way to unregister a static type.\n */\n classInit?(typeStruct: object): void;\n /**\n * Interfaces the new type implements on top of the ones it inherits, given as the interface values\n * themselves, such as `Gio.ListModel`. Their vtable slots are filled from the `vfunc`-prefixed methods on\n * the class's prototype chain, each of which has to match the interface's `Impl` type, such as\n * `Gio.ListModelImpl`.\n */\n implements?: Interface<TInstance>[];\n /**\n * Properties to install on the new type, keyed by the name JavaScript addresses each one by and\n * valued with the `GObject.ParamSpec` describing it. A key is read in camelCase however it is\n * written, so `dewPoint`, `dew_point` and `dew-point` all name the same member, and the ParamSpec\n * has to carry the canonical spelling of that name, `dew-point`, or registration throws: the\n * ParamSpec's name is the one GObject emits `notify` with, and a name the key does not spell\n * reaches nothing that listens for it. Every property gains prototype accessors, one for the key\n * as written, one for it with dashes turned into underscores and one for it in camelCase, each\n * unless the class already defines that name. They serve the value from storage of their own on\n * the instance, which is also what the type's `get_property` and `set_property` slots read and\n * write, so a value set from JavaScript, from `g_object_set_property` and at construction all\n * land in the same place.\n *\n * A write the ParamSpec would refuse throws rather than reaching GObject, which reports such a\n * write as a GLib critical and drops it: a `TypeError` for a read-only or construct-only\n * property and for a value of a type the property cannot hold, and a `RangeError` for a value\n * the ParamSpec rejects. The same checks run over a value handed to the constructor, where\n * a construct-only property is the one that is writable. An accepted write emits one `notify`,\n * which a `freeze_notify` batch collects; a write of the value the property already holds is\n * dropped and emits none.\n *\n * `null` and `undefined` both mean NULL, and mean it only where the ParamSpec's own type holds\n * NULL, which is a string, string-array, boxed, object, interface, param, variant or pointer\n * property. Such a property holds the `null` either spelling wrote, so the member, the type's\n * `get_property` slot and `g_object_get_property` serve the same thing, and writing the other\n * spelling over it emits no `notify`. Every other property, so every integer, floating-point,\n * boolean, enum, flags and GType one, refuses both with the same `TypeError` it refuses a\n * string with, and keeps the value it already holds. It refuses them for what it holds rather\n * than for its range, whatever that range is: the type is checked before the range, so a\n * `gint` whose range excludes 0 answers a nullish with that same `TypeError` and never with\n * the `RangeError` that names the value GObject would put in its place. The one place\n * `undefined` means something else is the constructor, which reads it as the property not\n * being given at all and leaves it at the ParamSpec's default, so a property is never handed a\n * value it cannot serve back.\n *\n * A floating-point property takes every JavaScript number, `NaN` and both infinities\n * included, and its ParamSpec alone rules on which of them the range admits: a `gdouble`\n * bounded by `-Infinity` and `Infinity` holds either infinity, and a magnitude a bounded\n * one excludes, like any `NaN`, comes back as the `RangeError` that names what GObject\n * would put in its place rather than as the `TypeError` a type the property cannot hold\n * earns. A `gfloat` property holds what GObject narrows the double to, so it serves `0.1`\n * back as `0.10000000149011612` and a finite magnitude no `gfloat` reaches as an infinity,\n * which the range then rules on in turn. That narrowing belongs to the property alone: the\n * same magnitude written to a `gfloat` through a generated binding, a signal argument or a\n * closure return is refused outright rather than narrowed.\n *\n * A generated property of a wrapped type answers a nullish differently, and the two halves of\n * the API disagree here: that property marshals what it is written through its descriptor\n * rather than through the checks above, so `new Gtk.Label({ widthRequest: null })` and a later\n * write of `null` to that member both land 0, where a `gint` installed here refuses both.\n *\n * A class that defines the camelCase member itself owns the property: its own accessor decides\n * what a write means, the other spellings forward to it, and the type's property slots read\n * and write it rather than the generated storage.\n */\n properties?: TProperties;\n /**\n * Signals to create on the new type, keyed by signal name and valued with the\n * {@link SignalSpec} describing each one. A name has to start with a letter, continue in\n * letters, digits, `-` and `_`, and be new to the type: one an ancestor type or a listed\n * interface already carries throws. The two word separators spell the same signal, so a\n * signal declared as `data_changed` is connected to and emitted as `data-changed` too.\n *\n * Instances connect and emit by name through the same `connect`, `on`, `once`, `off` and\n * `emit` surface inherited signals use: `registerClass` wraps `connect` and `emit` on the\n * class's prototype to serve the declared names, unless the class defines the member itself,\n * and hands every other name to the inherited implementation. A handler receives the\n * emission's arguments without the leading emitter, matching a generated signal, and what it\n * returns becomes the emission's return value when the signal declares one.\n *\n * The declared parameter GTypes rule the emission: `emit` takes exactly one argument per\n * declared parameter, throwing a `TypeError` for any other count, and converts each argument\n * into a `GValue` of the declared type, throwing for a value that type cannot hold. The signals\n * are created with no class closure of their own, but a method named `on<SignalName>`\n * becomes the signal's default handler, the way every `on`-prefixed method that names a\n * signal the type carries does; see {@link registerClass}.\n */\n signals?: TSignals;\n};\n\n/** {@link RegisterClassOptions} with the widest instance and property types {@link registerClass} accepts. */\ntype AnyRegisterClassOptions = RegisterClassOptions<object, Record<string, PropertySpec>, Record<string, SignalSpec>>;\ntype VfuncFn = NativeRegisterClassVfunc[\"fn\"];\ntype DiscoveredVfunc = VfuncDescriptor & { methodName: string; fn: VfuncFn };\ntype MethodTable = Map<string, VfuncFn>;\ntype InstanceMembers = { methods: MethodTable; names: Set<string>; inheritedNames: Set<string> };\n\ntype InterfaceVfuncBinding = {\n gtype: bigint;\n vfuncs: DiscoveredVfunc[];\n};\n\ntype PropertyVfuncSource = {\n klass: AnyClass;\n methods: MethodTable;\n dispatch: PropertyDispatch;\n adoptedTypes: bigint[];\n};\n\ntype PropertyVfuncSpec = {\n methodName: string;\n isValueOut: boolean;\n makeDispatch: (dispatch: PropertyDispatch) => VfuncFn;\n};\n\ntype ArgPatch = { isCallerAllocated: true } | { isCallScoped: true };\ntype DeclaredSignals = { native: NativeRegisterClassSignal[]; table: Map<string, DeclaredSignalTypes> };\n\ntype SignalMethodHost = {\n connect?: (signal: string, handler: SignalHandler, isAfter?: boolean) => number;\n emit?: (sigName: string, ...args: unknown[]) => unknown;\n};\n\nconst INSTANCE_ARG_INDEX = 0;\nconst VALUE_ARG_INDEX = 2;\nconst TEARDOWN_VFUNC_NAMES: Set<string> = new Set([\"dispose\", \"finalize\"]);\nconst ASYNC_INITABLE_TYPE_NAME = \"GAsyncInitable\";\nconst INIT_ASYNC_METHOD_NAME = \"vfuncInitAsync\";\n\nconst PROPERTY_VFUNC_SPECS: PropertyVfuncSpec[] = [\n { methodName: GET_PROPERTY_VFUNC, isValueOut: true, makeDispatch: makeGetProperty },\n { methodName: SET_PROPERTY_VFUNC, isValueOut: false, makeDispatch: makeSetProperty },\n];\n\nconst PROPERTY_VFUNC_NAMES: Set<string> = new Set(PROPERTY_VFUNC_SPECS.map((spec) => spec.methodName));\nconst TYPE_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9\\-_+]{2,}$/;\nconst SIGNAL_OVERRIDE_PATTERN = /^on[A-Z]/;\n\n/**\n * Registers a subclass of a wrapper class as a new GType, wiring up any class and interface\n * virtual functions it overrides, both for the interfaces it inherits and for the ones\n * `RegisterClassOptions.implements` names.\n *\n * Throws when the class does not extend a registered wrapper class, when it has no derivable type\n * name or the name is not a valid GType name, when an entry in\n * `RegisterClassOptions.implements` is not a registered interface, when a\n * listed interface has a prerequisite that neither the parent type nor another listed interface meets,\n * when the list names `Gio.AsyncInitable` as an interface the parent type does not already\n * implement and no method on the chain fills `vfuncInitAsync`, since the default `init_async`\n * would run `vfuncInit` on a worker thread, when an entry in\n * `RegisterClassOptions.properties` names its `GObject.ParamSpec` something other than the canonical\n * spelling of the key it sits under, when an entry in\n * `RegisterClassOptions.signals` carries an invalid name, a name the type already knows, a GType\n * that cannot hold a value, or an accumulator the spec does not admit, and when\n * `RegisterClassOptions.cssName` is\n * given for a class that does not extend `Gtk.Widget`. An exception thrown by\n * `RegisterClassOptions.classInit` also propagates, after the type has already been registered.\n *\n * A slot is filled from the `vfunc`-prefixed methods on the class's prototype chain, up to but not\n * including the registered ancestor the class extends, so a method an intermediate base class\n * declares fills a slot the same way one the class itself declares does. A slot nothing on that\n * chain fills is left untouched.\n *\n * Declare every slot as a method: a class field holding a function, such as `vfuncGetNItems = () => 1`,\n * is assigned to each instance after registration and never reaches the vtable.\n *\n * A method named `on<SignalName>` — the signal's name in camelCase after the `on`, so `onClicked`\n * for `clicked` and `onItemsChanged` for `items-changed` — becomes that signal's default handler\n * when the type carries the signal, whether an ancestor type or an implemented interface brings it\n * or `RegisterClassOptions.signals` declares it. The method is installed as a class-closure\n * override, so it runs on every emission, on the instances a native caller creates included, in\n * the stage the signal's flags name rather than alongside connected handlers. It receives the\n * emission's arguments without the leading emitter, with `this` bound to the emitter, and what it\n * returns becomes the emission's result when the signal declares one. The same discovery walks the\n * prototype chain vfunc discovery walks, and a subclass registering its own `on<SignalName>`\n * replaces the handler for its instances, where `super.on<SignalName>()` reaches the replaced one.\n * An `on`-prefixed method naming no signal the type carries is left alone as the ordinary method\n * it is.\n *\n * An override of `vfuncConstructed` runs from inside the base constructor, before JavaScript\n * installs the subclass's field initializers and runs its constructor body, so a field still\n * reads `undefined` there and reading a `#private` field throws. Declare state the override\n * touches without an initializer, and assign private state from the constructor body after\n * `super()`. An instance a native caller creates, through `GObject.newv` or `Gtk.Builder`,\n * never runs the subclass constructor at all, so its declared fields stay uninitialized for\n * the object's whole life.\n *\n * @param klass The subclass to register.\n * @param options What the new GType gains beyond the vtable slots the class overrides.\n * @returns The same class, now registered, with every name in `options.properties` in its property map.\n */\nfunction registerClass<\n T extends AnyClass,\n TProperties extends Record<string, PropertySpec> = Record<never, PropertySpec>,\n TSignals extends Record<string, SignalSpec> = Record<never, SignalSpec>,\n>(\n klass: T,\n options?: RegisterClassOptions<T[\"prototype\"], TProperties, TSignals>,\n): RegisteredClass<T, TProperties, TSignals>;\n\nfunction registerClass(klass: AnyClass, options: AnyRegisterClassOptions = {}): AnyClass {\n const parentType = resolveParentType(klass);\n\n if (parentType === TYPE_INVALID) {\n throw new TypeError(`registerClass: ${klass.name} must extend a registered wrapper class`);\n }\n\n const name = resolveTypeName(klass, options);\n const declaredTypes = resolveInterfaceTypes(klass, options.implements ?? []);\n const adoptedTypes = declaredTypes.filter((gtype) => !typeIsA(parentType, gtype));\n const properties = options.properties ?? {};\n const signals = resolveDeclaredSignals(klass, options.signals ?? {});\n const members = collectInstanceMembers(klass);\n const { methods, inheritedNames } = members;\n checkAsyncInitable(klass, adoptedTypes, methods);\n const dispatch = buildPropertyDispatch({ klass, properties, adoptedTypes });\n\n const classVfuncs = [\n ...discoverClassVfuncs(klass, methods),\n ...propertyVfuncs({ klass, methods, dispatch, adoptedTypes }),\n ];\n\n const claimedMethodNames = new Set(classVfuncs.map((vfunc) => vfunc.methodName));\n const interfaceBindings = discoverInterfaceBindings(methods, parentType, declaredTypes, claimedMethodNames);\n\n const nativeOptions = withNativeSignals(\n toNativeOptions(classVfuncs, interfaceBindings, properties, options),\n signals.native,\n );\n\n const newType: bigint = nativeRegisterClass(name, parentType, nativeOptions);\n registerClassType(klass, newType);\n markDerivedClass(klass);\n installSignalOverrides(newType, methods);\n applyInterfaceMixins(klass, adoptedTypes, inheritedNames);\n installDeclaredSignalMethods(klass, signals.table, members.names);\n invokeClassInit(options, newType);\n\n return klass;\n}\n\nfunction invokeClassInit(options: AnyRegisterClassOptions, newType: bigint): void {\n if (options.classInit === undefined) {\n return;\n }\n\n const structClass = getClassStructClass(newType);\n\n if (structClass === undefined) {\n throw new Error(\"registerClass: no ancestor of the new type registers a class struct wrapper\");\n }\n\n options.classInit(wrapHandle(getTypeClassHandle(newType), structClass));\n}\n\nfunction resolveTypeName(klass: AnyClass, options: AnyRegisterClassOptions): string {\n const name = options.typeName ?? klass.name;\n\n if (!name) {\n throw new TypeError(\"registerClass: cannot derive a GType name (anonymous class with no typeName option)\");\n }\n\n if (!TYPE_NAME_PATTERN.test(name)) {\n throw new TypeError(\n `registerClass: '${name}' is not a valid GType name (a letter or underscore, then at ` +\n \"least two more characters, all from A-Z, a-z, 0-9, '-', '_' and '+')\",\n );\n }\n\n return name;\n}\n\nfunction resolveInterfaceType(klass: AnyClass, entry: AnyClass): bigint {\n const gtype = getClassType(entry);\n\n if (typeFundamental(gtype) !== TYPE_INTERFACE) {\n const label = typeof entry === \"function\" ? entry.name : String(entry);\n\n throw new TypeError(\n `registerClass: ${klass.name} lists '${label}' in implements, which is not a registered interface`,\n );\n }\n\n return gtype;\n}\n\nfunction resolveInterfaceTypes(klass: AnyClass, entries: AnyClass[]): bigint[] {\n return [...new Set(entries.map((entry) => resolveInterfaceType(klass, entry)))];\n}\n\nfunction checkAsyncInitable(klass: AnyClass, adoptedTypes: bigint[], methods: MethodTable): void {\n const isAsyncInitable = adoptedTypes.some((gtype) => typeName(gtype) === ASYNC_INITABLE_TYPE_NAME);\n\n if (isAsyncInitable && !methods.has(INIT_ASYNC_METHOD_NAME)) {\n throw new TypeError(\n `registerClass: ${klass.name} implements Gio.AsyncInitable without overriding 'vfuncInitAsync'; ` +\n \"the default 'init_async' would run 'vfuncInit' on a worker thread\",\n );\n }\n}\n\nfunction applyInterfaceMixins(klass: AnyClass, adoptedTypes: bigint[], inheritedNames: Set<string>): void {\n for (const gtype of adoptedTypes) {\n const mixin = getInterfaceMixin(gtype);\n\n if (mixin !== undefined) {\n insertMixinLayer(klass, mixin, inheritedNames);\n }\n }\n}\n\nfunction resolveParentType(klass: AnyClass): bigint {\n return (\n walkClassChain(getParentClass(klass), (cls) => {\n const gtype = getClassType(cls);\n\n return gtype === TYPE_INVALID ? undefined : gtype;\n }) ?? TYPE_INVALID\n );\n}\n\nfunction addOwnMember(members: InstanceMembers, proto: object, name: string, isInherited: boolean): void {\n if (name === \"constructor\") {\n return;\n }\n\n if (isInherited) {\n members.inheritedNames.add(name);\n }\n\n if (members.names.has(name)) {\n return;\n }\n\n members.names.add(name);\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n\n if (typeof descriptor?.value === \"function\") {\n members.methods.set(name, descriptor.value as VfuncFn);\n }\n}\n\nfunction addOwnMembers(members: InstanceMembers, klass: AnyClass, isInherited: boolean): void {\n const proto = (klass as { prototype?: object }).prototype;\n\n if (proto === undefined) {\n return;\n }\n\n for (const name of Object.getOwnPropertyNames(proto)) {\n addOwnMember(members, proto, name, isInherited);\n }\n}\n\nfunction collectInstanceMembers(klass: AnyClass): InstanceMembers {\n const members: InstanceMembers = { methods: new Map(), names: new Set(), inheritedNames: new Set() };\n let cls: AnyClass | null = klass;\n\n while (cls !== null && getClassType(cls) === TYPE_INVALID) {\n addOwnMembers(members, cls, cls !== klass);\n cls = getParentClass(cls);\n }\n\n return members;\n}\n\nfunction buildDiscoveredVfunc(\n fn: VfuncFn,\n methodName: string,\n resolveDescriptor: (methodName: string) => VfuncDescriptor | undefined,\n skip: Set<string> | undefined,\n): DiscoveredVfunc | undefined {\n if (skip?.has(methodName)) {\n return undefined;\n }\n\n const descriptor = resolveDescriptor(methodName);\n\n if (!descriptor) {\n return undefined;\n }\n\n const argDescriptors = slotArgDescriptors(descriptor);\n\n return {\n ...descriptor,\n methodName,\n argDescriptors,\n fn: wrapVfunc(fn, argDescriptors, descriptor),\n };\n}\n\nfunction collectDiscoveredVfuncs(\n methods: MethodTable,\n resolveDescriptor: (methodName: string) => VfuncDescriptor | undefined,\n skip?: Set<string>,\n): DiscoveredVfunc[] {\n const result: DiscoveredVfunc[] = [];\n\n for (const [methodName, fn] of methods) {\n const discovered = buildDiscoveredVfunc(fn, methodName, resolveDescriptor, skip);\n\n if (discovered) {\n result.push(discovered);\n }\n }\n\n return result;\n}\n\nfunction discoverClassVfuncs(klass: AnyClass, methods: MethodTable): DiscoveredVfunc[] {\n return collectDiscoveredVfuncs(\n methods,\n (methodName) => findClassVfuncDescriptor(klass, methodName) ?? undefined,\n PROPERTY_VFUNC_NAMES,\n );\n}\n\nfunction wrapVfunc(\n fn: VfuncFn,\n argDescriptors: NativeRegisterClassVfunc[\"argDescriptors\"],\n descriptor: VfuncDescriptor,\n): VfuncFn {\n return wrapCallback(\n fn as (...args: unknown[]) => unknown,\n { argDescriptors, returnDescriptor: descriptor.returnDescriptor },\n \"vfunc\",\n );\n}\n\nfunction discoverInterfaceBindings(\n methods: MethodTable,\n parentGtype: bigint,\n declaredTypes: bigint[],\n claimedMethodNames: Set<string>,\n): InterfaceVfuncBinding[] {\n const declared: Set<bigint> = new Set(declaredTypes);\n const gtypes: Set<bigint> = new Set([...typeInterfaces(parentGtype), ...declaredTypes]);\n const bindings: InterfaceVfuncBinding[] = [];\n\n for (const gtype of gtypes) {\n const vfuncs = discoverInterfaceVfuncs(methods, gtype, claimedMethodNames);\n\n if (vfuncs.length > 0 || declared.has(gtype)) {\n bindings.push({ gtype, vfuncs });\n }\n }\n\n return bindings;\n}\n\nfunction discoverInterfaceVfuncs(\n methods: MethodTable,\n interfaceGtype: bigint,\n claimedMethodNames: Set<string>,\n): DiscoveredVfunc[] {\n return collectDiscoveredVfuncs(\n methods,\n (methodName) => findInterfaceVfuncDescriptor(interfaceGtype, methodName),\n claimedMethodNames,\n );\n}\n\nconst hasDispatchedProperties = (dispatch: PropertyDispatch, adoptedTypes: bigint[]): boolean =>\n dispatch.accessors.length > 0 || adoptedTypes.length > 0;\n\nfunction propertyVfuncFor(\n source: PropertyVfuncSource,\n spec: PropertyVfuncSpec,\n): DiscoveredVfunc | undefined {\n const { klass, methods, dispatch, adoptedTypes } = source;\n\n const dispatched = hasDispatchedProperties(dispatch, adoptedTypes)\n ? spec.makeDispatch(dispatch)\n : undefined;\n\n const fn = methods.get(spec.methodName) ?? dispatched;\n\n return fn === undefined ? undefined : buildPropertyVfunc(klass, spec.methodName, fn, spec.isValueOut);\n}\n\nfunction propertyVfuncs(source: PropertyVfuncSource): DiscoveredVfunc[] {\n return PROPERTY_VFUNC_SPECS.map((spec) => propertyVfuncFor(source, spec)).filter(\n (vfunc) => vfunc !== undefined,\n );\n}\n\nfunction markArg(argDescriptors: Descriptor[], index: number, patch: ArgPatch): Descriptor[] {\n return argDescriptors.map((arg, at) => (at === index ? { ...arg, ...patch } : arg));\n}\n\nfunction isTeardownSlot(descriptor: VfuncDescriptor): boolean {\n return (\n TEARDOWN_VFUNC_NAMES.has(descriptor.vfuncName) &&\n descriptor.argDescriptors[INSTANCE_ARG_INDEX]?.kind === \"object\"\n );\n}\n\nfunction slotArgDescriptors(descriptor: VfuncDescriptor): Descriptor[] {\n if (!isTeardownSlot(descriptor)) {\n return descriptor.argDescriptors;\n }\n\n return markArg(descriptor.argDescriptors, INSTANCE_ARG_INDEX, { isCallScoped: true });\n}\n\nfunction buildPropertyVfunc(\n klass: AnyClass,\n methodName: string,\n fn: VfuncFn,\n isValueOut: boolean,\n): DiscoveredVfunc {\n const descriptor = findClassVfuncDescriptor(klass, methodName);\n\n if (!descriptor) {\n throw new Error(`registerClass: the parent class exposes no '${methodName}' vtable slot`);\n }\n\n const argDescriptors = isValueOut\n ? markArg(descriptor.argDescriptors, VALUE_ARG_INDEX, { isCallerAllocated: true })\n : descriptor.argDescriptors;\n\n return {\n ...descriptor,\n methodName,\n argDescriptors,\n fn: wrapVfunc(fn, argDescriptors, descriptor),\n };\n}\n\nconst canonicalSignalName = (name: string): string => name.replaceAll(\"_\", \"-\");\n\nfunction installSignalOverrides(newType: bigint, methods: MethodTable): void {\n for (const [methodName, fn] of methods) {\n if (!SIGNAL_OVERRIDE_PATTERN.test(methodName)) {\n continue;\n }\n\n const handler = fn as (...args: unknown[]) => unknown;\n\n overrideSignalClassClosure(newType, kebabCase(methodName.slice(2)), (...args: unknown[]) =>\n handler.apply(args[0], args.slice(1)),\n );\n }\n}\n\nfunction resolveSignalGType(klass: AnyClass, signalName: string, role: string, entry: SignalGType): bigint {\n if (typeof entry === \"bigint\") {\n return entry;\n }\n\n const gtype = getClassType(entry);\n\n if (gtype === TYPE_INVALID) {\n throw new TypeError(\n `registerClass: signal '${signalName}' of ${klass.name} names a class with no registered ` +\n `GType as its ${role}`,\n );\n }\n\n return gtype;\n}\n\nfunction resolveSignalReturnType(klass: AnyClass, name: string, spec: SignalSpec): bigint | undefined {\n if (spec.returnType === undefined) {\n return undefined;\n }\n\n const returnType = resolveSignalGType(klass, name, \"return type\", spec.returnType);\n\n return returnType === TYPE_NONE ? undefined : returnType;\n}\n\nfunction resolveDeclaredSignal(\n klass: AnyClass,\n name: string,\n spec: SignalSpec,\n): { native: NativeRegisterClassSignal; declared: DeclaredSignalTypes } {\n const paramTypes = (spec.paramTypes ?? []).map((entry, index) =>\n resolveSignalGType(klass, name, `parameter ${String(index)}`, entry),\n );\n\n const returnType = resolveSignalReturnType(klass, name, spec);\n const native: NativeRegisterClassSignal = { name, paramTypes };\n const declared: DeclaredSignalTypes = { paramTypes };\n\n if (spec.flags !== undefined) {\n native.flags = spec.flags;\n }\n\n if (spec.accumulator !== undefined) {\n native.accumulator = spec.accumulator;\n }\n\n if (returnType !== undefined) {\n native.returnType = returnType;\n declared.returnType = returnType;\n }\n\n return { native, declared };\n}\n\nfunction resolveDeclaredSignals(klass: AnyClass, signals: Record<string, SignalSpec>): DeclaredSignals {\n const native: NativeRegisterClassSignal[] = [];\n const table: Map<string, DeclaredSignalTypes> = new Map();\n\n for (const [name, spec] of Object.entries(signals)) {\n const resolved = resolveDeclaredSignal(klass, name, spec);\n native.push(resolved.native);\n table.set(canonicalSignalName(name), resolved.declared);\n }\n\n return { native, table };\n}\n\nfunction inheritedSignalMethod<T>(inherited: T | undefined, signal: string): T {\n if (inherited === undefined) {\n throw new Error(`Unknown signal '${signal}'`);\n }\n\n return inherited;\n}\n\nfunction installDeclaredConnect(\n proto: SignalMethodHost,\n findDeclared: (signal: string) => DeclaredSignalTypes | undefined,\n): void {\n const inheritedConnect = proto.connect;\n\n proto.connect = function connect(\n this: object,\n signal: string,\n handler: SignalHandler,\n isAfter?: boolean,\n ): number {\n if (findDeclared(signal) === undefined) {\n return inheritedSignalMethod(inheritedConnect, signal).call(this, signal, handler, isAfter);\n }\n\n return connectClosureSignal(this, signal, handler, isAfter ?? false);\n };\n}\n\nfunction installDeclaredEmit(\n proto: SignalMethodHost,\n findDeclared: (signal: string) => DeclaredSignalTypes | undefined,\n): void {\n const inheritedEmit = proto.emit;\n\n proto.emit = function emit(this: object, sigName: string, ...args: unknown[]): unknown {\n const declared = findDeclared(sigName);\n\n if (declared === undefined) {\n return inheritedSignalMethod(inheritedEmit, sigName).call(this, sigName, ...args);\n }\n\n return emitDeclaredSignal(this, sigName, declared, args);\n };\n}\n\nfunction installDeclaredSignalMethods(\n klass: AnyClass,\n table: Map<string, DeclaredSignalTypes>,\n definedNames: Set<string>,\n): void {\n if (table.size === 0) {\n return;\n }\n\n const proto = klass.prototype as SignalMethodHost;\n\n const findDeclared = (signal: string): DeclaredSignalTypes | undefined =>\n table.get(canonicalSignalName(getSignalBaseName(signal)));\n\n if (!definedNames.has(\"connect\")) {\n installDeclaredConnect(proto, findDeclared);\n }\n\n if (!definedNames.has(\"emit\")) {\n installDeclaredEmit(proto, findDeclared);\n }\n}\n\nfunction toNativeInterface(binding: InterfaceVfuncBinding): NativeRegisterClassInterface {\n const nativeInterface: NativeRegisterClassInterface = {\n type: binding.gtype,\n vfuncs: [...binding.vfuncs],\n };\n\n const vtableSize = binding.vfuncs[0]?.vtableSize;\n\n if (vtableSize !== undefined) {\n nativeInterface.vtableSize = vtableSize;\n }\n\n return nativeInterface;\n}\n\nfunction withNativeSignals(\n options: NativeRegisterClassOptions | undefined,\n signals: NativeRegisterClassSignal[],\n): NativeRegisterClassOptions | undefined {\n if (signals.length === 0) {\n return options;\n }\n\n return { ...options, signals };\n}\n\nfunction applyNativeTypeOptions(options: NativeRegisterClassOptions, source: AnyRegisterClassOptions): void {\n if (source.abstract ?? false) {\n options.abstract = true;\n }\n\n if (source.cssName !== undefined) {\n options.cssName = source.cssName;\n }\n}\n\nfunction toNativeOptions(\n classVfuncs: DiscoveredVfunc[],\n interfaceBindings: InterfaceVfuncBinding[],\n properties: Record<string, PropertySpec>,\n source: AnyRegisterClassOptions,\n): NativeRegisterClassOptions | undefined {\n const options: NativeRegisterClassOptions = {};\n applyNativeTypeOptions(options, source);\n\n if (Object.keys(properties).length > 0) {\n options.properties = toNativeProperties(properties);\n }\n\n if (classVfuncs.length > 0) {\n options.vfuncs = [...classVfuncs];\n }\n\n if (interfaceBindings.length > 0) {\n options.interfaces = interfaceBindings.map((binding) => toNativeInterface(binding));\n }\n\n return Object.keys(options).length > 0 ? options : undefined;\n}\n\nexport { type Interface, registerClass, type SignalGType, type SignalSpec };\n"]}
@@ -1,6 +1,6 @@
1
1
  import { type ExternalObject, type Handle, type RegisterClassVfunc as NativeRegisterClassVfunc } from "@gtkx/native";
2
2
  import { type AnyClass } from "@gtkx/utils";
3
- import type { Mixin } from "./mixin.js";
3
+ import { type Mixin } from "./mixin.js";
4
4
  import { type TypedClass } from "./type.js";
5
5
  /**
6
6
  * Static side of class `C` with its construct signature preserved but the members named `K`
@@ -46,6 +46,11 @@ type VfuncDescriptor = {
46
46
  * overrides each one.
47
47
  */
48
48
  type VfuncRegistry = Record<string, VfuncDescriptor>;
49
+ /**
50
+ * Picks the wrapper class for one handle of a registered type, such as a subclass keyed on a tag the
51
+ * handle carries.
52
+ */
53
+ type WrapperClassResolver = (handle: ExternalObject<Handle>) => AnyClass;
49
54
  /**
50
55
  * How one property an interface declares reaches the vtable, given as the interface's own accessor
51
56
  * members. A direction introspection does not route through a vtable slot is left out, and the
@@ -85,6 +90,7 @@ declare function getClassType(cls: AnyClass | undefined): bigint;
85
90
  * the nearest registered ancestor.
86
91
  */
87
92
  declare function getInstanceType(instance: object): bigint;
93
+ declare function coerceGType(value: unknown): unknown;
88
94
  declare function registerClassType(cls: AnyClass, type: bigint): void;
89
95
  /**
90
96
  * Registers a wrapper class as the JS representation of a GType, optionally
@@ -95,7 +101,42 @@ declare function registerClassType(cls: AnyClass, type: bigint): void;
95
101
  * overrides.
96
102
  */
97
103
  declare function registerWrapperClass(cls: AnyClass, type: bigint, vfuncs?: VfuncRegistry): void;
104
+ /**
105
+ * Lets a class registered with `registerWrapperClass` pick a subclass for each handle it wraps, for
106
+ * types whose one GType covers several C-level subtypes, the way a cairo surface reports image or
107
+ * recording through `cairo_surface_get_type`. The resolver runs when a handle is wrapped as that class
108
+ * explicitly, the way a boxed value a binding hands back is; a wrapper resolved from a handle's runtime
109
+ * GType never consults it, and a subclass passed to `wrapHandle` directly is used as given.
110
+ * @param cls Registered wrapper class whose handles the resolver classifies.
111
+ * @param resolver Returns the class to instantiate for one handle, `cls` itself included.
112
+ * @throws If `cls` is not a registered wrapper class.
113
+ */
114
+ declare function registerWrapperClassResolver(cls: AnyClass, resolver: WrapperClassResolver): void;
98
115
  declare function markDerivedClass(cls: AnyClass): void;
116
+ /**
117
+ * Registers the wrapper class of a type's class struct, such as `Gtk.WidgetClass` for `Gtk.Widget`,
118
+ * so `registerClass` can hand a `classInit` hook the new type's class struct wrapped in it.
119
+ * @param cls Wrapper class of the type's instances, already registered through
120
+ * `registerWrapperClass`.
121
+ * @param structClass Wrapper class of the type's class struct.
122
+ */
123
+ declare function registerClassStruct(cls: AnyClass, structClass: AnyClass): void;
124
+ declare function getClassStructClass(type: bigint): AnyClass | undefined;
125
+ declare function getTypeClassHandle(gtype: bigint): ExternalObject<Handle>;
126
+ /**
127
+ * Returns a GObject type's class struct, wrapped in the class-struct wrapper classes registered
128
+ * for the type's ancestry, such as `Gtk.WidgetClass` composed with `GObject.ObjectClass` for a
129
+ * widget type. The class is referenced so it exists even before the type's first instance, and
130
+ * the reference is deliberately never released: once created, a class struct lives for the rest
131
+ * of the process. Backs the `peek` statics of generated GTypeStruct wrappers, such as
132
+ * `GObject.ObjectClass.peek` and `Gtk.WidgetClass.peek`.
133
+ *
134
+ * @param type GType to peek the class struct of, or a registered wrapper class of the type.
135
+ * @param base When given, wrapper class of the type the peeked type must derive from; the peek
136
+ * throws for a type outside that lineage. Without it any GObject type is accepted.
137
+ * @returns The wrapped class struct.
138
+ */
139
+ declare function peekTypeClass(type: bigint | AnyClass, base?: AnyClass): object;
99
140
  declare function resolveWrapperType(instance: object): bigint;
100
141
  /**
101
142
  * Registers a GInterface, associating its GType with a mixin used to compose the
@@ -111,8 +152,9 @@ declare function registerInterface(cls: AnyClass, type: bigint, mixin: Mixin, la
111
152
  * Wraps a native handle in a JS wrapper instance. With no class, resolves and
112
153
  * reuses the wrapper for the handle's runtime GType (composing interface mixins),
113
154
  * and hands back an instance that already carries a handle unchanged; with an
114
- * explicit class, creates a bare instance backed by the handle. Returns null for
115
- * a null or undefined handle.
155
+ * explicit class, creates a bare instance backed by the handle, of the subclass the
156
+ * class's `registerWrapperClassResolver` resolver picks when it has one. Returns null
157
+ * for a null or undefined handle.
116
158
  * @param handle Native handle to wrap.
117
159
  * @param cls Wrapper class to instantiate, or omitted to resolve it from the runtime type.
118
160
  */
@@ -121,6 +163,7 @@ declare function wrapHandle<T extends object>(handle: ExternalObject<Handle>, cl
121
163
  declare function wrapHandle<T extends object>(handle: ExternalObject<Handle> | null | undefined, cls: AnyClass<T>): T | null;
122
164
  declare function wrapHandle(handle: ExternalObject<Handle>, cls?: AnyClass): TypedClass;
123
165
  declare function wrapHandle(handle: ExternalObject<Handle> | null | undefined, cls?: AnyClass): TypedClass | null;
166
+ declare function wrapFundamentalHandle(handle: ExternalObject<Handle> | null | undefined, cls: AnyClass): object | null;
124
167
  /**
125
168
  * Returns the wrapper class registered for a GType, walking up to ancestor types,
126
169
  * and throws if none is registered.
@@ -131,6 +174,7 @@ declare function getInterfaceMixin(type: bigint): Mixin | undefined;
131
174
  declare function wrapObject(value: unknown): object | null;
132
175
  declare function wrapCallScopedObject(value: unknown): object | null;
133
176
  declare function instanceClassName(instance: object): string;
177
+ declare function describeValueKind(value: unknown): string;
134
178
  /** Returns the native handle bound to a wrapper instance, throwing if none is set. */
135
179
  declare function getHandle(instance: object): ExternalObject<Handle>;
136
180
  /** Associates a native handle with a wrapper instance. */
@@ -139,5 +183,5 @@ declare function registerWrapper(handle: ExternalObject<Handle>, instance: objec
139
183
  declare function getVfuncRegistry(cls: object): VfuncRegistry | undefined;
140
184
  declare function getInterfaceVfuncRegistry(type: bigint): VfuncRegistry | undefined;
141
185
  declare function getInterfaceProperties(type: bigint): Record<string, InterfaceProperty> | undefined;
142
- export { getClassType, getInstanceType, markDerivedClass, registerClassType, registerWrapperClass, registerInterface, wrapHandle, getWrapperClass, resolveWrapperClass, getHandle, setHandle, getVfuncRegistry, getInterfaceMixin, getInterfaceProperties, getInterfaceVfuncRegistry, instanceClassName, registerWrapper, resolveWrapperType, wrapCallScopedObject, wrapObject, type InterfaceProperty, type StaticBase, type VfuncDescriptor, };
186
+ export { coerceGType, describeValueKind, getClassStructClass, getClassType, getInstanceType, getTypeClassHandle, markDerivedClass, peekTypeClass, registerClassStruct, registerClassType, registerWrapperClass, registerWrapperClassResolver, registerInterface, wrapFundamentalHandle, wrapHandle, getWrapperClass, resolveWrapperClass, getHandle, setHandle, getVfuncRegistry, getInterfaceMixin, getInterfaceProperties, getInterfaceVfuncRegistry, instanceClassName, registerWrapper, resolveWrapperType, wrapCallScopedObject, wrapObject, type InterfaceProperty, type StaticBase, type VfuncDescriptor, type WrapperClassResolver, };
143
187
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.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C,CAQ3D;AAED,0DAA0D;AAC1D,iBAAS,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,CAEzE;AAMD,iBAAS,eAAe,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAG/E;AAMD,iBAAS,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAEhE;AAED,iBAAS,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAE1E;AAED,iBAAS,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS,CAE3F;AAED,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,oBAAoB,GAC5B,CAAC"}
package/dist/registry.js CHANGED
@@ -1,7 +1,10 @@
1
- import { getType, getWrapper, setWrapper, } from "@gtkx/native";
1
+ import { getFundamentalWrapper, getType, getTypeClass, getWrapper, setFundamentalWrapper, setWrapper, } from "@gtkx/native";
2
2
  import { walkClassChain } from "@gtkx/utils";
3
- import { TYPE_INVALID, typeInterfaces, typeIsA, typeName, typeParent } from "./type.js";
3
+ import { copyLayerMembers } from "./mixin.js";
4
+ import { TYPE_INVALID, TYPE_OBJECT, typeInterfaces, typeIsA, typeName, typeParent, } from "./type.js";
4
5
  const classRegistry = new Map();
6
+ const classStructRegistry = new Map();
7
+ const composedClassStructRegistry = new Map();
5
8
  const interfaceMixinRegistry = new Map();
6
9
  const composedClassRegistry = new Map();
7
10
  const handleMap = new WeakMap();
@@ -9,6 +12,8 @@ const vfuncRegistry = new WeakMap();
9
12
  const interfaceLayoutRegistry = new Map();
10
13
  const wrapperClasses = new WeakSet();
11
14
  const derivedClasses = new WeakSet();
15
+ const typeClassHandles = new Map();
16
+ const wrapperClassResolvers = new WeakMap();
12
17
  function setClassType(cls, type) {
13
18
  cls.prototype.__type__ = type;
14
19
  }
@@ -34,6 +39,13 @@ function getInstanceType(instance) {
34
39
  const handle = handleMap.get(instance);
35
40
  return handle === undefined ? TYPE_INVALID : getType(handle);
36
41
  }
42
+ function coerceGType(value) {
43
+ if (typeof value !== "function") {
44
+ return value;
45
+ }
46
+ const type = getClassType(value);
47
+ return type === TYPE_INVALID ? value : type;
48
+ }
37
49
  function registerClassType(cls, type) {
38
50
  if (type === TYPE_INVALID) {
39
51
  return;
@@ -58,9 +70,118 @@ function registerWrapperClass(cls, type, vfuncs) {
58
70
  registerVfuncRegistry(cls, vfuncs);
59
71
  }
60
72
  }
73
+ /**
74
+ * Lets a class registered with `registerWrapperClass` pick a subclass for each handle it wraps, for
75
+ * types whose one GType covers several C-level subtypes, the way a cairo surface reports image or
76
+ * recording through `cairo_surface_get_type`. The resolver runs when a handle is wrapped as that class
77
+ * explicitly, the way a boxed value a binding hands back is; a wrapper resolved from a handle's runtime
78
+ * GType never consults it, and a subclass passed to `wrapHandle` directly is used as given.
79
+ * @param cls Registered wrapper class whose handles the resolver classifies.
80
+ * @param resolver Returns the class to instantiate for one handle, `cls` itself included.
81
+ * @throws If `cls` is not a registered wrapper class.
82
+ */
83
+ function registerWrapperClassResolver(cls, resolver) {
84
+ if (!wrapperClasses.has(cls)) {
85
+ throw new Error(`Cannot register a wrapper class resolver for ${cls.name}: ` +
86
+ "register the class with registerWrapperClass first");
87
+ }
88
+ wrapperClassResolvers.set(cls, resolver);
89
+ }
61
90
  function markDerivedClass(cls) {
62
91
  derivedClasses.add(cls);
63
92
  }
93
+ /**
94
+ * Registers the wrapper class of a type's class struct, such as `Gtk.WidgetClass` for `Gtk.Widget`,
95
+ * so `registerClass` can hand a `classInit` hook the new type's class struct wrapped in it.
96
+ * @param cls Wrapper class of the type's instances, already registered through
97
+ * `registerWrapperClass`.
98
+ * @param structClass Wrapper class of the type's class struct.
99
+ */
100
+ function registerClassStruct(cls, structClass) {
101
+ const type = getClassType(cls);
102
+ if (type !== TYPE_INVALID) {
103
+ classStructRegistry.set(type, structClass);
104
+ }
105
+ }
106
+ function collectClassStructClasses(type) {
107
+ const structs = [];
108
+ let current = type;
109
+ while (current !== TYPE_INVALID) {
110
+ const structClass = classStructRegistry.get(current);
111
+ if (structClass !== undefined) {
112
+ structs.push(structClass);
113
+ }
114
+ current = typeParent(current);
115
+ }
116
+ return structs;
117
+ }
118
+ function composeClassStructClass(structs) {
119
+ const [nearest, ...ancestors] = structs;
120
+ if (nearest === undefined || ancestors.length === 0) {
121
+ return nearest;
122
+ }
123
+ const composed = class extends nearest {
124
+ };
125
+ Object.defineProperty(composed, "name", { value: nearest.name });
126
+ for (const structClass of ancestors) {
127
+ copyLayerMembers(composed, structClass.prototype);
128
+ }
129
+ return composed;
130
+ }
131
+ function getClassStructClass(type) {
132
+ const cached = composedClassStructRegistry.get(type);
133
+ if (cached !== undefined) {
134
+ return cached;
135
+ }
136
+ const composed = composeClassStructClass(collectClassStructClasses(type));
137
+ if (composed !== undefined) {
138
+ composedClassStructRegistry.set(type, composed);
139
+ }
140
+ return composed;
141
+ }
142
+ function peekedTypeLabel(type, gtype) {
143
+ const name = typeName(gtype);
144
+ if (name !== null) {
145
+ return name;
146
+ }
147
+ return typeof type === "bigint" ? String(type) : type.name;
148
+ }
149
+ function getTypeClassHandle(gtype) {
150
+ const cached = typeClassHandles.get(gtype);
151
+ if (cached !== undefined) {
152
+ return cached;
153
+ }
154
+ const handle = getTypeClass(gtype);
155
+ typeClassHandles.set(gtype, handle);
156
+ return handle;
157
+ }
158
+ /**
159
+ * Returns a GObject type's class struct, wrapped in the class-struct wrapper classes registered
160
+ * for the type's ancestry, such as `Gtk.WidgetClass` composed with `GObject.ObjectClass` for a
161
+ * widget type. The class is referenced so it exists even before the type's first instance, and
162
+ * the reference is deliberately never released: once created, a class struct lives for the rest
163
+ * of the process. Backs the `peek` statics of generated GTypeStruct wrappers, such as
164
+ * `GObject.ObjectClass.peek` and `Gtk.WidgetClass.peek`.
165
+ *
166
+ * @param type GType to peek the class struct of, or a registered wrapper class of the type.
167
+ * @param base When given, wrapper class of the type the peeked type must derive from; the peek
168
+ * throws for a type outside that lineage. Without it any GObject type is accepted.
169
+ * @returns The wrapped class struct.
170
+ */
171
+ function peekTypeClass(type, base) {
172
+ const gtype = typeof type === "bigint" ? type : getClassType(type);
173
+ if (!typeIsA(gtype, TYPE_OBJECT)) {
174
+ throw new TypeError(`peekTypeClass: '${peekedTypeLabel(type, gtype)}' is not a GObject type`);
175
+ }
176
+ if (base !== undefined && !typeIsA(gtype, getClassType(base))) {
177
+ throw new TypeError(`peekTypeClass: '${peekedTypeLabel(type, gtype)}' does not derive from '${base.name}'`);
178
+ }
179
+ const structClass = getClassStructClass(gtype);
180
+ if (structClass === undefined) {
181
+ throw new TypeError(`peekTypeClass: no ancestor of '${peekedTypeLabel(type, gtype)}' registers a class struct wrapper`);
182
+ }
183
+ return wrapHandle(getTypeClassHandle(gtype), structClass);
184
+ }
64
185
  function resolveAncestorType(ancestor) {
65
186
  if (derivedClasses.has(ancestor) || !wrapperClasses.has(ancestor)) {
66
187
  return undefined;
@@ -100,8 +221,22 @@ function wrapHandle(handle, cls) {
100
221
  if (cls === undefined) {
101
222
  return getOrCreateWrapper(handle);
102
223
  }
224
+ const resolver = wrapperClassResolvers.get(cls);
225
+ const instance = Object.create((resolver === undefined ? cls : resolver(handle)).prototype);
226
+ setHandle(instance, handle);
227
+ return instance;
228
+ }
229
+ function wrapFundamentalHandle(handle, cls) {
230
+ if (handle === null || handle === undefined) {
231
+ return null;
232
+ }
233
+ const existing = getFundamentalWrapper(handle);
234
+ if (existing) {
235
+ return existing;
236
+ }
103
237
  const instance = Object.create(cls.prototype);
104
238
  setHandle(instance, handle);
239
+ setFundamentalWrapper(handle, instance);
105
240
  return instance;
106
241
  }
107
242
  /**
@@ -206,6 +341,15 @@ function getOrCreateWrapper(handle) {
206
341
  function instanceClassName(instance) {
207
342
  return instance.constructor?.name ?? "object";
208
343
  }
344
+ function describeValueKind(value) {
345
+ if (value === null) {
346
+ return "null";
347
+ }
348
+ if (typeof value !== "object") {
349
+ return typeof value;
350
+ }
351
+ return instanceClassName(value);
352
+ }
209
353
  /** Returns the native handle bound to a wrapper instance, throwing if none is set. */
210
354
  function getHandle(instance) {
211
355
  const handle = handleMap.get(instance);
@@ -237,5 +381,5 @@ function getInterfaceVfuncRegistry(type) {
237
381
  function getInterfaceProperties(type) {
238
382
  return interfaceLayoutRegistry.get(type)?.properties;
239
383
  }
240
- export { getClassType, getInstanceType, markDerivedClass, registerClassType, registerWrapperClass, registerInterface, wrapHandle, getWrapperClass, resolveWrapperClass, getHandle, setHandle, getVfuncRegistry, getInterfaceMixin, getInterfaceProperties, getInterfaceVfuncRegistry, instanceClassName, registerWrapper, resolveWrapperType, wrapCallScopedObject, wrapObject, };
384
+ export { coerceGType, describeValueKind, getClassStructClass, getClassType, getInstanceType, getTypeClassHandle, markDerivedClass, peekTypeClass, registerClassStruct, registerClassType, registerWrapperClass, registerWrapperClassResolver, registerInterface, wrapFundamentalHandle, wrapHandle, getWrapperClass, resolveWrapperClass, getHandle, setHandle, getVfuncRegistry, getInterfaceMixin, getInterfaceProperties, getInterfaceVfuncRegistry, instanceClassName, registerWrapper, resolveWrapperType, wrapCallScopedObject, wrapObject, };
241
385
  //# sourceMappingURL=registry.js.map