@gtkx/runtime 1.2.2 → 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
package/dist/object.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Descriptor, type ExternalObject, type Handle } from "@gtkx/native";
1
+ import { type Descriptor } from "@gtkx/native";
2
2
  import { type AnyClass } from "@gtkx/utils";
3
3
  /**
4
4
  * One construct property a wrapper class accepts: the canonical `GObject` name it is set under,
@@ -28,17 +28,24 @@ declare function registerConstructProperties(cls: AnyClass, bindings: ConstructB
28
28
  * for a read-only property and for a value of a type the property cannot hold, and
29
29
  * a `RangeError` for a value the ParamSpec rejects. A value marshalled through a
30
30
  * declared descriptor is converted rather than checked, so a `null` handed to a
31
- * numeric one of those lands 0 rather than being refused.
31
+ * numeric one of those lands 0 rather than being refused, and a number is fitted to
32
+ * the property first, as `coerceObjectProperty` does: truncated toward zero for a
33
+ * whole-number property and clamped to the range its `GObject.ParamSpec` allows.
32
34
  * Properties whose value is `undefined` are skipped. A type registered with
33
35
  * `registerClass` binds the wrapper before its `constructed` slot runs, so an
34
36
  * override of that slot already sees a usable instance.
37
+ * When construction returns an object that already has a wrapper — it reached
38
+ * JavaScript and was wrapped before `g_object_new` returned, for example a
39
+ * `Gtk.Window` observed through the toplevels list — that existing wrapper is
40
+ * returned instead of binding `wrapper`, so both references stay one object.
35
41
  *
36
42
  * @param gtype The GType of the object to construct.
37
43
  * @param props Property names mapped to the values to set them to.
38
44
  * @param wrapper The wrapper instance to bind to the new object.
39
- * @returns The handle of the newly created object.
45
+ * @returns The wrapper bound to the constructed object: `wrapper` itself, or
46
+ * the wrapper the object already had.
40
47
  */
41
- declare function newObjectWithProperties(gtype: bigint, props: object, wrapper: object): ExternalObject<Handle>;
48
+ declare function newObjectWithProperties<T extends object>(gtype: bigint, props: object, wrapper: T): T;
42
49
  /**
43
50
  * Reads a GObject property and converts it to its JavaScript value using the
44
51
  * descriptor.
@@ -52,8 +59,9 @@ declare function getObjectProperty(obj: object, propertyName: string, descriptor
52
59
  * Writes a JavaScript value to a GObject property, converting it to native form
53
60
  * using the descriptor. The descriptor converts what it is given rather than checking it against
54
61
  * the property's `GObject.ParamSpec`, so `null` and `undefined` written to a numeric or enum
55
- * property land 0, where the same write to a property installed through `registerClass` is
56
- * refused with a `TypeError`.
62
+ * property land 0, and a fractional number written to a whole-number property is truncated toward
63
+ * zero, where the same writes to a property installed through `registerClass` are refused with a
64
+ * `TypeError`.
57
65
  *
58
66
  * @param obj The object to write to.
59
67
  * @param propertyName The property name.
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAa,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAQ5D;;;GAGG;AACH,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAC/D,wGAAwG;AACxG,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAmE1D;;;;;;;;;GASG;AACH,iBAAS,2BAA2B,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAGrF;AAoBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAkBtG;AAED;;;;;;;GAOG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAK7F;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAE5G;AAED,OAAO,EACH,uBAAuB,EACvB,iBAAiB,EACjB,2BAA2B,EAC3B,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACzB,CAAC"}
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAA+C,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,aAAa,CAAC;AAQ5D;;;GAGG;AACH,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAC/D,wGAAwG;AACxG,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAmE1D;;;;;;;;;GASG;AACH,iBAAS,2BAA2B,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAGrF;AAoBD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,iBAAS,uBAAuB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAsB9F;AAED;;;;;;;GAOG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAK7F;AAED;;;;;;;;;;;;GAYG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAE5G;AAED,OAAO,EACH,uBAAuB,EACvB,iBAAiB,EACjB,2BAA2B,EAC3B,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACzB,CAAC"}
package/dist/object.js CHANGED
@@ -3,9 +3,9 @@ import { getParentClass } from "@gtkx/utils";
3
3
  import { bind } from "./bind.js";
4
4
  import { objectT, stringT, voidT } from "./descriptors.js";
5
5
  import { LIB, VALUE_T } from "./library.js";
6
- import { constructPropertyFor } from "./properties.js";
6
+ import { coercePropertyValue, constructPropertyFor } from "./properties.js";
7
7
  import { getHandle, registerWrapper } from "./registry.js";
8
- import { fromValue, newValueForDescriptor, toValue } from "./value.js";
8
+ import { fromValueForDescriptor, newValueForDescriptor, toValue } from "./value.js";
9
9
  const declaredBindings = new WeakMap();
10
10
  const resolvedBindings = new WeakMap();
11
11
  const declarations = { generation: 0 };
@@ -66,7 +66,7 @@ function constructPropertyForEntry(source, name, value) {
66
66
  if (binding === undefined) {
67
67
  return constructPropertyFor(source.gtype, name, value, source.wrapper);
68
68
  }
69
- return { name: binding[0], value: toValue(binding[1], value) };
69
+ return { name: binding[0], value: toValue(binding[1], coercePropertyValue(source.gtype, binding[0], value)) };
70
70
  }
71
71
  /**
72
72
  * Constructs a new GObject of the given type, setting the supplied construct
@@ -78,15 +78,22 @@ function constructPropertyForEntry(source, name, value) {
78
78
  * for a read-only property and for a value of a type the property cannot hold, and
79
79
  * a `RangeError` for a value the ParamSpec rejects. A value marshalled through a
80
80
  * declared descriptor is converted rather than checked, so a `null` handed to a
81
- * numeric one of those lands 0 rather than being refused.
81
+ * numeric one of those lands 0 rather than being refused, and a number is fitted to
82
+ * the property first, as `coerceObjectProperty` does: truncated toward zero for a
83
+ * whole-number property and clamped to the range its `GObject.ParamSpec` allows.
82
84
  * Properties whose value is `undefined` are skipped. A type registered with
83
85
  * `registerClass` binds the wrapper before its `constructed` slot runs, so an
84
86
  * override of that slot already sees a usable instance.
87
+ * When construction returns an object that already has a wrapper — it reached
88
+ * JavaScript and was wrapped before `g_object_new` returned, for example a
89
+ * `Gtk.Window` observed through the toplevels list — that existing wrapper is
90
+ * returned instead of binding `wrapper`, so both references stay one object.
85
91
  *
86
92
  * @param gtype The GType of the object to construct.
87
93
  * @param props Property names mapped to the values to set them to.
88
94
  * @param wrapper The wrapper instance to bind to the new object.
89
- * @returns The handle of the newly created object.
95
+ * @returns The wrapper bound to the constructed object: `wrapper` itself, or
96
+ * the wrapper the object already had.
90
97
  */
91
98
  function newObjectWithProperties(gtype, props, wrapper) {
92
99
  const names = [];
@@ -100,8 +107,11 @@ function newObjectWithProperties(gtype, props, wrapper) {
100
107
  values.push(property.value);
101
108
  }
102
109
  }
103
- newObject(gtype, names, values, wrapper, registerWrapper);
104
- return getHandle(wrapper);
110
+ const existing = newObject(gtype, names, values, wrapper, registerWrapper);
111
+ if (existing !== null) {
112
+ return existing;
113
+ }
114
+ return wrapper;
105
115
  }
106
116
  /**
107
117
  * Reads a GObject property and converts it to its JavaScript value using the
@@ -114,14 +124,15 @@ function newObjectWithProperties(gtype, props, wrapper) {
114
124
  function getObjectProperty(obj, propertyName, descriptor) {
115
125
  const value = newValueForDescriptor(descriptor);
116
126
  gObjectGetProperty(getHandle(obj), propertyName, value);
117
- return fromValue(value);
127
+ return fromValueForDescriptor(descriptor, value);
118
128
  }
119
129
  /**
120
130
  * Writes a JavaScript value to a GObject property, converting it to native form
121
131
  * using the descriptor. The descriptor converts what it is given rather than checking it against
122
132
  * the property's `GObject.ParamSpec`, so `null` and `undefined` written to a numeric or enum
123
- * property land 0, where the same write to a property installed through `registerClass` is
124
- * refused with a `TypeError`.
133
+ * property land 0, and a fractional number written to a whole-number property is truncated toward
134
+ * zero, where the same writes to a property installed through `registerClass` are refused with a
135
+ * `TypeError`.
125
136
  *
126
137
  * @param obj The object to write to.
127
138
  * @param propertyName The property name.
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,SAAS,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAiB,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAA0B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M,KAAK,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAChD,kBAAkB,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IAExD,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,iBAAiB,CAAC,GAAW,EAAE,YAAoB,EAAE,UAAsB,EAAE,OAAgB;IAClG,kBAAkB,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AACnF,CAAC;AAED,OAAO,EACH,uBAAuB,EACvB,iBAAiB,EACjB,2BAA2B,EAC3B,iBAAiB,GAGpB,CAAC","sourcesContent":["import { type Descriptor, type ExternalObject, type Handle, newObject } from \"@gtkx/native\";\nimport { type AnyClass, getParentClass } from \"@gtkx/utils\";\nimport { bind } from \"./bind.js\";\nimport { objectT, stringT, voidT } from \"./descriptors.js\";\nimport { LIB, VALUE_T } from \"./library.js\";\nimport { type ConstructProperty, constructPropertyFor } from \"./properties.js\";\nimport { getHandle, registerWrapper } from \"./registry.js\";\nimport { fromValue, newValueForDescriptor, toValue } from \"./value.js\";\n\n/**\n * One construct property a wrapper class accepts: the canonical `GObject` name it is set under,\n * and the descriptor its value is marshalled through.\n */\ntype ConstructBinding = [name: string, descriptor: Descriptor];\n/** The construct properties a wrapper class accepts, keyed by the camelCased name callers give them. */\ntype ConstructBindings = Record<string, ConstructBinding>;\ntype ResolvedBindings = { generation: number; bindings: ConstructBindings };\n\nconst declaredBindings: WeakMap<AnyClass, ConstructBindings> = new WeakMap();\nconst resolvedBindings: WeakMap<AnyClass, ResolvedBindings> = new WeakMap();\nconst declarations = { generation: 0 };\nconst NO_BINDINGS: ConstructBindings = Object.create(null) as ConstructBindings;\n\nconst gObjectGetProperty = bind(\n LIB,\n \"g_object_get_property\",\n [objectT(\"borrowed\"), stringT(\"borrowed\"), VALUE_T],\n voidT,\n);\n\nconst gObjectSetProperty = bind(\n LIB,\n \"g_object_set_property\",\n [objectT(\"borrowed\"), stringT(\"borrowed\"), VALUE_T],\n voidT,\n);\n\nfunction collectDeclaredBindings(cls: AnyClass): ConstructBindings[] {\n const declared: ConstructBindings[] = [];\n let current: AnyClass | null = cls;\n\n while (current !== null) {\n const own = declaredBindings.get(current);\n\n if (own !== undefined) {\n declared.push(own);\n }\n\n current = getParentClass(current);\n }\n\n return declared;\n}\n\nfunction mergeDeclaredBindings(cls: AnyClass): ConstructBindings {\n const declared = collectDeclaredBindings(cls);\n const merged: ConstructBindings = Object.create(null) as ConstructBindings;\n\n for (let index = declared.length - 1; index >= 0; index--) {\n Object.assign(merged, declared[index]);\n }\n\n return merged;\n}\n\nfunction constructBindingsFor(cls: AnyClass | undefined): ConstructBindings {\n if (cls === undefined) {\n return NO_BINDINGS;\n }\n\n const cached = resolvedBindings.get(cls);\n\n if (cached?.generation === declarations.generation) {\n return cached.bindings;\n }\n\n const bindings = mergeDeclaredBindings(cls);\n resolvedBindings.set(cls, { generation: declarations.generation, bindings });\n\n return bindings;\n}\n\n/**\n * Declares the construct properties a wrapper class accepts, so `newObjectWithProperties`\n * marshals each one through its descriptor rather than resolving it from the\n * `GObject.ParamSpec` the type installs. A class inherits the declarations of its ancestors.\n * Registering takes effect immediately, including for classes already constructed from and for\n * subclasses that already inherited an earlier declaration.\n *\n * @param cls The wrapper class the properties are declared on.\n * @param bindings CamelCased property names mapped to their canonical name and descriptor.\n */\nfunction registerConstructProperties(cls: AnyClass, bindings: ConstructBindings): void {\n declaredBindings.set(cls, bindings);\n declarations.generation += 1;\n}\n\nfunction constructPropertyForEntry(\n source: { gtype: bigint; bindings: ConstructBindings; wrapper: object },\n name: string,\n value: unknown,\n): ConstructProperty | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n const binding = source.bindings[name];\n\n if (binding === undefined) {\n return constructPropertyFor(source.gtype, name, value, source.wrapper);\n }\n\n return { name: binding[0], value: toValue(binding[1], value) };\n}\n\n/**\n * Constructs a new GObject of the given type, setting the supplied construct\n * properties, and binds `wrapper` to it. A property the wrapper's class declares\n * through `registerConstructProperties` is marshalled through its descriptor; any\n * other one is marshalled through the `GObject.ParamSpec` the type installs under\n * that name, dashed or camelCased, and is skipped when the type installs none.\n * A value that ParamSpec would refuse throws before GObject sees it: a `TypeError`\n * for a read-only property and for a value of a type the property cannot hold, and\n * a `RangeError` for a value the ParamSpec rejects. A value marshalled through a\n * declared descriptor is converted rather than checked, so a `null` handed to a\n * numeric one of those lands 0 rather than being refused.\n * Properties whose value is `undefined` are skipped. A type registered with\n * `registerClass` binds the wrapper before its `constructed` slot runs, so an\n * override of that slot already sees a usable instance.\n *\n * @param gtype The GType of the object to construct.\n * @param props Property names mapped to the values to set them to.\n * @param wrapper The wrapper instance to bind to the new object.\n * @returns The handle of the newly created object.\n */\nfunction newObjectWithProperties(gtype: bigint, props: object, wrapper: object): ExternalObject<Handle> {\n const names: string[] = [];\n const values: ExternalObject<Handle>[] = [];\n const bindings = constructBindingsFor(wrapper.constructor as AnyClass | undefined);\n const source = { gtype, bindings, wrapper };\n\n for (const name of Object.keys(props)) {\n const property = constructPropertyForEntry(source, name, Reflect.get(props, name));\n\n if (property !== undefined) {\n names.push(property.name);\n values.push(property.value);\n }\n }\n\n newObject(gtype, names, values, wrapper, registerWrapper);\n\n return getHandle(wrapper);\n}\n\n/**\n * Reads a GObject property and converts it to its JavaScript value using the\n * descriptor.\n *\n * @param obj The object to read from.\n * @param propertyName The property name.\n * @param descriptor Describes the property's type.\n */\nfunction getObjectProperty(obj: object, propertyName: string, descriptor: Descriptor): unknown {\n const value = newValueForDescriptor(descriptor);\n gObjectGetProperty(getHandle(obj), propertyName, value);\n\n return fromValue(value);\n}\n\n/**\n * Writes a JavaScript value to a GObject property, converting it to native form\n * using the descriptor. The descriptor converts what it is given rather than checking it against\n * the property's `GObject.ParamSpec`, so `null` and `undefined` written to a numeric or enum\n * property land 0, where the same write to a property installed through `registerClass` is\n * refused with a `TypeError`.\n *\n * @param obj The object to write to.\n * @param propertyName The property name.\n * @param descriptor Describes the property's type.\n * @param jsValue The value to set.\n */\nfunction setObjectProperty(obj: object, propertyName: string, descriptor: Descriptor, jsValue: unknown): void {\n gObjectSetProperty(getHandle(obj), propertyName, toValue(descriptor, jsValue));\n}\n\nexport {\n newObjectWithProperties,\n getObjectProperty,\n registerConstructProperties,\n setObjectProperty,\n type ConstructBinding,\n type ConstructBindings,\n};\n"]}
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,SAAS,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAiB,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAA0B,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAWpF,MAAM,gBAAgB,GAAyC,IAAI,OAAO,EAAE,CAAC;AAC7E,MAAM,gBAAgB,GAAwC,IAAI,OAAO,EAAE,CAAC;AAC5E,MAAM,YAAY,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;AACvC,MAAM,WAAW,GAAsB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAsB,CAAC;AAEhF,MAAM,kBAAkB,GAAG,IAAI,CAC3B,GAAG,EACH,uBAAuB,EACvB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,E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E,OAAO,CAAC,CAAC,CAAC;AACnF,CAAC;AAED,OAAO,EACH,uBAAuB,EACvB,iBAAiB,EACjB,2BAA2B,EAC3B,iBAAiB,GAGpB,CAAC","sourcesContent":["import { type Descriptor, type ExternalObject, type Handle, newObject } from \"@gtkx/native\";\nimport { type AnyClass, getParentClass } from \"@gtkx/utils\";\nimport { bind } from \"./bind.js\";\nimport { objectT, stringT, voidT } from \"./descriptors.js\";\nimport { LIB, VALUE_T } from \"./library.js\";\nimport { coercePropertyValue, type ConstructProperty, constructPropertyFor } from \"./properties.js\";\nimport { getHandle, registerWrapper } from \"./registry.js\";\nimport { fromValueForDescriptor, newValueForDescriptor, toValue } from \"./value.js\";\n\n/**\n * One construct property a wrapper class accepts: the canonical `GObject` name it is set under,\n * and the descriptor its value is marshalled through.\n */\ntype ConstructBinding = [name: string, descriptor: Descriptor];\n/** The construct properties a wrapper class accepts, keyed by the camelCased name callers give them. */\ntype ConstructBindings = Record<string, ConstructBinding>;\ntype ResolvedBindings = { generation: number; bindings: ConstructBindings };\n\nconst declaredBindings: WeakMap<AnyClass, ConstructBindings> = new WeakMap();\nconst resolvedBindings: WeakMap<AnyClass, ResolvedBindings> = new WeakMap();\nconst declarations = { generation: 0 };\nconst NO_BINDINGS: ConstructBindings = Object.create(null) as ConstructBindings;\n\nconst gObjectGetProperty = bind(\n LIB,\n \"g_object_get_property\",\n [objectT(\"borrowed\"), stringT(\"borrowed\"), VALUE_T],\n voidT,\n);\n\nconst gObjectSetProperty = bind(\n LIB,\n \"g_object_set_property\",\n [objectT(\"borrowed\"), stringT(\"borrowed\"), VALUE_T],\n voidT,\n);\n\nfunction collectDeclaredBindings(cls: AnyClass): ConstructBindings[] {\n const declared: ConstructBindings[] = [];\n let current: AnyClass | null = cls;\n\n while (current !== null) {\n const own = declaredBindings.get(current);\n\n if (own !== undefined) {\n declared.push(own);\n }\n\n current = getParentClass(current);\n }\n\n return declared;\n}\n\nfunction mergeDeclaredBindings(cls: AnyClass): ConstructBindings {\n const declared = collectDeclaredBindings(cls);\n const merged: ConstructBindings = Object.create(null) as ConstructBindings;\n\n for (let index = declared.length - 1; index >= 0; index--) {\n Object.assign(merged, declared[index]);\n }\n\n return merged;\n}\n\nfunction constructBindingsFor(cls: AnyClass | undefined): ConstructBindings {\n if (cls === undefined) {\n return NO_BINDINGS;\n }\n\n const cached = resolvedBindings.get(cls);\n\n if (cached?.generation === declarations.generation) {\n return cached.bindings;\n }\n\n const bindings = mergeDeclaredBindings(cls);\n resolvedBindings.set(cls, { generation: declarations.generation, bindings });\n\n return bindings;\n}\n\n/**\n * Declares the construct properties a wrapper class accepts, so `newObjectWithProperties`\n * marshals each one through its descriptor rather than resolving it from the\n * `GObject.ParamSpec` the type installs. A class inherits the declarations of its ancestors.\n * Registering takes effect immediately, including for classes already constructed from and for\n * subclasses that already inherited an earlier declaration.\n *\n * @param cls The wrapper class the properties are declared on.\n * @param bindings CamelCased property names mapped to their canonical name and descriptor.\n */\nfunction registerConstructProperties(cls: AnyClass, bindings: ConstructBindings): void {\n declaredBindings.set(cls, bindings);\n declarations.generation += 1;\n}\n\nfunction constructPropertyForEntry(\n source: { gtype: bigint; bindings: ConstructBindings; wrapper: object },\n name: string,\n value: unknown,\n): ConstructProperty | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n const binding = source.bindings[name];\n\n if (binding === undefined) {\n return constructPropertyFor(source.gtype, name, value, source.wrapper);\n }\n\n return { name: binding[0], value: toValue(binding[1], coercePropertyValue(source.gtype, binding[0], value)) };\n}\n\n/**\n * Constructs a new GObject of the given type, setting the supplied construct\n * properties, and binds `wrapper` to it. A property the wrapper's class declares\n * through `registerConstructProperties` is marshalled through its descriptor; any\n * other one is marshalled through the `GObject.ParamSpec` the type installs under\n * that name, dashed or camelCased, and is skipped when the type installs none.\n * A value that ParamSpec would refuse throws before GObject sees it: a `TypeError`\n * for a read-only property and for a value of a type the property cannot hold, and\n * a `RangeError` for a value the ParamSpec rejects. A value marshalled through a\n * declared descriptor is converted rather than checked, so a `null` handed to a\n * numeric one of those lands 0 rather than being refused, and a number is fitted to\n * the property first, as `coerceObjectProperty` does: truncated toward zero for a\n * whole-number property and clamped to the range its `GObject.ParamSpec` allows.\n * Properties whose value is `undefined` are skipped. A type registered with\n * `registerClass` binds the wrapper before its `constructed` slot runs, so an\n * override of that slot already sees a usable instance.\n * When construction returns an object that already has a wrapper — it reached\n * JavaScript and was wrapped before `g_object_new` returned, for example a\n * `Gtk.Window` observed through the toplevels list — that existing wrapper is\n * returned instead of binding `wrapper`, so both references stay one object.\n *\n * @param gtype The GType of the object to construct.\n * @param props Property names mapped to the values to set them to.\n * @param wrapper The wrapper instance to bind to the new object.\n * @returns The wrapper bound to the constructed object: `wrapper` itself, or\n * the wrapper the object already had.\n */\nfunction newObjectWithProperties<T extends object>(gtype: bigint, props: object, wrapper: T): T {\n const names: string[] = [];\n const values: ExternalObject<Handle>[] = [];\n const bindings = constructBindingsFor(wrapper.constructor as AnyClass | undefined);\n const source = { gtype, bindings, wrapper };\n\n for (const name of Object.keys(props)) {\n const property = constructPropertyForEntry(source, name, Reflect.get(props, name));\n\n if (property !== undefined) {\n names.push(property.name);\n values.push(property.value);\n }\n }\n\n const existing = newObject(gtype, names, values, wrapper, registerWrapper);\n\n if (existing !== null) {\n return existing as T;\n }\n\n return wrapper;\n}\n\n/**\n * Reads a GObject property and converts it to its JavaScript value using the\n * descriptor.\n *\n * @param obj The object to read from.\n * @param propertyName The property name.\n * @param descriptor Describes the property's type.\n */\nfunction getObjectProperty(obj: object, propertyName: string, descriptor: Descriptor): unknown {\n const value = newValueForDescriptor(descriptor);\n gObjectGetProperty(getHandle(obj), propertyName, value);\n\n return fromValueForDescriptor(descriptor, value);\n}\n\n/**\n * Writes a JavaScript value to a GObject property, converting it to native form\n * using the descriptor. The descriptor converts what it is given rather than checking it against\n * the property's `GObject.ParamSpec`, so `null` and `undefined` written to a numeric or enum\n * property land 0, and a fractional number written to a whole-number property is truncated toward\n * zero, where the same writes to a property installed through `registerClass` are refused with a\n * `TypeError`.\n *\n * @param obj The object to write to.\n * @param propertyName The property name.\n * @param descriptor Describes the property's type.\n * @param jsValue The value to set.\n */\nfunction setObjectProperty(obj: object, propertyName: string, descriptor: Descriptor, jsValue: unknown): void {\n gObjectSetProperty(getHandle(obj), propertyName, toValue(descriptor, jsValue));\n}\n\nexport {\n newObjectWithProperties,\n getObjectProperty,\n registerConstructProperties,\n setObjectProperty,\n type ConstructBinding,\n type ConstructBindings,\n};\n"]}
@@ -1,11 +1,41 @@
1
1
  import { type ExternalObject, type Handle } from "@gtkx/native";
2
2
  type ValueGuard = (value: unknown) => boolean;
3
+ declare const INT32_MINIMUM = -2147483648;
4
+ declare const INT32_MAXIMUM = 2147483647;
5
+ declare const INT64_MINIMUM: bigint;
6
+ declare const INT64_MAXIMUM: bigint;
7
+ declare const UINT64_MAXIMUM: bigint;
8
+ declare const WHOLE_NUMBER_RANGES: Map<bigint, [minimum: number, maximum: number]>;
3
9
  declare const getParamFlags: (pspec: ExternalObject<Handle>) => number;
4
10
  declare const getParamValueType: (pspec: ExternalObject<Handle>) => bigint;
11
+ /**
12
+ * Reads the `GParamFlags` bitfield of a `GObject.ParamSpec`.
13
+ *
14
+ * @param spec The param spec wrapper to read.
15
+ * @returns The spec's flags.
16
+ */
17
+ declare const getParamSpecFlags: (spec: object) => number;
18
+ /**
19
+ * Reads the GType of the values a `GObject.ParamSpec` describes.
20
+ *
21
+ * @param spec The param spec wrapper to read.
22
+ * @returns The GType of the spec's values.
23
+ */
24
+ declare const getParamSpecValueType: (spec: object) => bigint;
25
+ /**
26
+ * Reads the GType a `GObject.ParamSpec` is installed on.
27
+ *
28
+ * @param spec The param spec wrapper to read.
29
+ * @returns The owning GType, or `TYPE_INVALID` while the spec is not installed on any type.
30
+ */
31
+ declare const getParamSpecOwnerType: (spec: object) => bigint;
5
32
  declare const isParamWritable: (flags: number) => boolean;
6
33
  declare const isParamConstructOnly: (flags: number) => boolean;
7
34
  declare const isParamLaxlyValidated: (flags: number) => boolean;
35
+ declare const isParamExplicitlyNotified: (flags: number) => boolean;
8
36
  declare const wasParamValueModified: (pspec: ExternalObject<Handle>, value: ExternalObject<Handle>) => boolean;
37
+ declare function isStringArray(value: unknown[]): boolean;
38
+ declare function resolveGtype(value: unknown): bigint;
9
39
  declare function valueGuardFor(valueType: bigint): ValueGuard;
10
- export { getParamFlags, getParamValueType, isParamConstructOnly, isParamLaxlyValidated, isParamWritable, type ValueGuard, valueGuardFor, wasParamValueModified, };
40
+ export { WHOLE_NUMBER_RANGES, getParamFlags, getParamSpecFlags, getParamSpecOwnerType, getParamSpecValueType, getParamValueType, INT32_MAXIMUM, INT32_MINIMUM, INT64_MAXIMUM, INT64_MINIMUM, isParamConstructOnly, isStringArray, isParamExplicitlyNotified, isParamLaxlyValidated, isParamWritable, resolveGtype, UINT64_MAXIMUM, type ValueGuard, valueGuardFor, wasParamValueModified, };
11
41
  //# sourceMappingURL=param-spec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"param-spec.d.ts","sourceRoot":"","sources":["../src/param-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAQ,MAAM,cAAc,CAAC;AAkCtE,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;AA6D9C,QAAA,MAAM,aAAa,GAAI,OAAO,cAAc,CAAC,MAAM,CAAC,KAAG,MAA2D,CAAC;AAEnH,QAAA,MAAM,iBAAiB,GAAI,OAAO,cAAc,CAAC,MAAM,CAAC,KAAG,MACE,CAAC;AAE9D,QAAA,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,OAAyC,CAAC;AACnF,QAAA,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,OAA+C,CAAC;AAC9F,QAAA,MAAM,qBAAqB,GAAI,OAAO,MAAM,KAAG,OAA+C,CAAC;AAE/F,QAAA,MAAM,qBAAqB,GAAI,OAAO,cAAc,CAAC,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,eAAe,GAAI,OAAO,MAAM,KAAG,OAAyC,CAAC;AACnF,QAAA,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,OAA+C,CAAC;AAC9F,QAAA,MAAM,qBAAqB,GAAI,OAAO,MAAM,KAAG,OAA+C,CAAC;AAC/F,QAAA,MAAM,yBAAyB,GAAI,OAAO,MAAM,KAAG,OAAgD,CAAC;AAEpG,QAAA,MAAM,qBAAqB,GAAI,OAAO,cAAc,CAAC,MAAM,CAAC,EAAE,OAAO,cAAc,CAAC,MAAM,CAAC,KAAG,OAC/C,CAAC;AAUhD,iBAAS,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAQhD;AAsCD,iBAAS,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQ5C;AAcD,iBAAS,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAepD;AA4CD,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,KAAK,UAAU,EACf,aAAa,EACb,qBAAqB,GACxB,CAAC"}
@@ -2,15 +2,17 @@ import { read } from "@gtkx/native";
2
2
  import { bind } from "./bind.js";
3
3
  import { biguint64T, booleanT, stringT, uint32T, voidT } from "./descriptors.js";
4
4
  import { LIB, PARAM_T, VALUE_T } from "./library.js";
5
- import { getInstanceType } from "./registry.js";
5
+ import { getHandle, getInstanceType } from "./registry.js";
6
6
  import { getStrvType, isTypedClass, TYPE_BOOLEAN, TYPE_BOXED, TYPE_CHAR, TYPE_DOUBLE, TYPE_ENUM, TYPE_FLAGS, TYPE_FLOAT, TYPE_GTYPE, TYPE_INT, TYPE_INT64, TYPE_INTERFACE, TYPE_INVALID, TYPE_LONG, TYPE_OBJECT, TYPE_PARAM, TYPE_POINTER, TYPE_STRING, TYPE_UCHAR, TYPE_UINT, TYPE_UINT64, TYPE_ULONG, TYPE_VARIANT, typeFundamental, typeIsA, } from "./type.js";
7
7
  const PARAM_READABLE = 1;
8
8
  const PARAM_WRITABLE = 2;
9
9
  const PARAM_CONSTRUCT_ONLY = 8;
10
10
  const PARAM_LAX_VALIDATION = 16;
11
+ const PARAM_EXPLICIT_NOTIFY = 1 << 30;
11
12
  const READ_FLAGS = PARAM_READABLE | PARAM_WRITABLE | PARAM_CONSTRUCT_ONLY | PARAM_LAX_VALIDATION;
12
13
  const FLAGS_BYTE_OFFSET = 16;
13
14
  const VALUE_TYPE_BYTE_OFFSET = 24;
15
+ const OWNER_TYPE_BYTE_OFFSET = 32;
14
16
  const LAYOUT_PROBE_NAME = "gtkx-param-layout";
15
17
  const INT8_MINIMUM = -128;
16
18
  const INT8_MAXIMUM = 127;
@@ -29,6 +31,19 @@ const WRAPPED_FUNDAMENTALS = new Set([
29
31
  TYPE_VARIANT,
30
32
  ]);
31
33
  const isWideUnsignedValue = wideIntegerGuardFor(0n, UINT64_MAXIMUM);
34
+ const MAX_SAFE = Number.MAX_SAFE_INTEGER;
35
+ const WHOLE_NUMBER_RANGES = new Map([
36
+ [TYPE_CHAR, [INT8_MINIMUM, INT8_MAXIMUM]],
37
+ [TYPE_UCHAR, [0, UINT8_MAXIMUM]],
38
+ [TYPE_INT, [INT32_MINIMUM, INT32_MAXIMUM]],
39
+ [TYPE_UINT, [0, UINT32_MAXIMUM]],
40
+ [TYPE_ENUM, [INT32_MINIMUM, INT32_MAXIMUM]],
41
+ [TYPE_FLAGS, [0, UINT32_MAXIMUM]],
42
+ [TYPE_LONG, [-MAX_SAFE, MAX_SAFE]],
43
+ [TYPE_ULONG, [0, MAX_SAFE]],
44
+ [TYPE_INT64, [-MAX_SAFE, MAX_SAFE]],
45
+ [TYPE_UINT64, [0, MAX_SAFE]],
46
+ ]);
32
47
  const SCALAR_GUARDS = new Map([
33
48
  [TYPE_BOOLEAN, isBooleanValue],
34
49
  [TYPE_STRING, isStringValue],
@@ -53,9 +68,41 @@ const paramSpecRefSink = bind(LIB, "g_param_spec_ref_sink", [PARAM_T], PARAM_T);
53
68
  const newParamSpecBoolean = bind(LIB, "g_param_spec_boolean", [stringT("borrowed"), stringT("borrowed"), stringT("borrowed"), booleanT, uint32T], PARAM_T);
54
69
  const getParamFlags = (pspec) => read(pspec, uint32T, FLAGS_BYTE_OFFSET);
55
70
  const getParamValueType = (pspec) => read(pspec, biguint64T, VALUE_TYPE_BYTE_OFFSET);
71
+ const getParamOwnerType = (pspec) => read(pspec, biguint64T, OWNER_TYPE_BYTE_OFFSET);
72
+ /**
73
+ * Reads the `GParamFlags` bitfield of a `GObject.ParamSpec`.
74
+ *
75
+ * @param spec The param spec wrapper to read.
76
+ * @returns The spec's flags.
77
+ */
78
+ const getParamSpecFlags = (spec) => {
79
+ assertParamLayout();
80
+ return getParamFlags(getHandle(spec));
81
+ };
82
+ /**
83
+ * Reads the GType of the values a `GObject.ParamSpec` describes.
84
+ *
85
+ * @param spec The param spec wrapper to read.
86
+ * @returns The GType of the spec's values.
87
+ */
88
+ const getParamSpecValueType = (spec) => {
89
+ assertParamLayout();
90
+ return getParamValueType(getHandle(spec));
91
+ };
92
+ /**
93
+ * Reads the GType a `GObject.ParamSpec` is installed on.
94
+ *
95
+ * @param spec The param spec wrapper to read.
96
+ * @returns The owning GType, or `TYPE_INVALID` while the spec is not installed on any type.
97
+ */
98
+ const getParamSpecOwnerType = (spec) => {
99
+ assertParamLayout();
100
+ return getParamOwnerType(getHandle(spec));
101
+ };
56
102
  const isParamWritable = (flags) => (flags & PARAM_WRITABLE) !== 0;
57
103
  const isParamConstructOnly = (flags) => (flags & PARAM_CONSTRUCT_ONLY) !== 0;
58
104
  const isParamLaxlyValidated = (flags) => (flags & PARAM_LAX_VALIDATION) !== 0;
105
+ const isParamExplicitlyNotified = (flags) => (flags & PARAM_EXPLICIT_NOTIFY) !== 0;
59
106
  const wasParamValueModified = (pspec, value) => paramValueValidate(pspec, value);
60
107
  function isBooleanValue(value) {
61
108
  return typeof value === "boolean";
@@ -63,8 +110,16 @@ function isBooleanValue(value) {
63
110
  function isStringValue(value) {
64
111
  return value == null || typeof value === "string";
65
112
  }
113
+ function isStringArray(value) {
114
+ for (const item of value) {
115
+ if (typeof item !== "string") {
116
+ return false;
117
+ }
118
+ }
119
+ return true;
120
+ }
66
121
  function isStrvValue(value) {
67
- return value == null || (Array.isArray(value) && value.every((item) => typeof item === "string"));
122
+ return value == null || (Array.isArray(value) && isStringArray(value));
68
123
  }
69
124
  function isNumberValue(value) {
70
125
  return typeof value === "number";
@@ -122,7 +177,11 @@ function readProbeLayout(flags) {
122
177
  const probe = newParamSpecBoolean(LAYOUT_PROBE_NAME, null, null, false, flags);
123
178
  paramSpecRefSink(probe);
124
179
  try {
125
- return { flags: getParamFlags(probe), valueType: getParamValueType(probe) };
180
+ return {
181
+ flags: getParamFlags(probe),
182
+ valueType: getParamValueType(probe),
183
+ ownerType: getParamOwnerType(probe),
184
+ };
126
185
  }
127
186
  finally {
128
187
  paramSpecUnref(probe);
@@ -130,7 +189,9 @@ function readProbeLayout(flags) {
130
189
  }
131
190
  function isLayoutIntact(flags) {
132
191
  const layout = readProbeLayout(flags);
133
- return (layout.flags & READ_FLAGS) === flags && layout.valueType === TYPE_BOOLEAN;
192
+ return ((layout.flags & READ_FLAGS) === flags &&
193
+ layout.valueType === TYPE_BOOLEAN &&
194
+ layout.ownerType === TYPE_INVALID);
134
195
  }
135
196
  function assertParamLayout() {
136
197
  if (layout.wasChecked) {
@@ -143,5 +204,5 @@ function assertParamLayout() {
143
204
  }
144
205
  throw new Error("GParamSpec does not match the memory layout this build reads a property's flags and value type at");
145
206
  }
146
- export { getParamFlags, getParamValueType, isParamConstructOnly, isParamLaxlyValidated, isParamWritable, valueGuardFor, wasParamValueModified, };
207
+ export { WHOLE_NUMBER_RANGES, getParamFlags, getParamSpecFlags, getParamSpecOwnerType, getParamSpecValueType, getParamValueType, INT32_MAXIMUM, INT32_MINIMUM, INT64_MAXIMUM, INT64_MINIMUM, isParamConstructOnly, isStringArray, isParamExplicitlyNotified, isParamLaxlyValidated, isParamWritable, resolveGtype, UINT64_MAXIMUM, valueGuardFor, wasParamValueModified, };
147
208
  //# sourceMappingURL=param-spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"param-spec.js","sourceRoot":"","sources":["../src/param-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,IAAI,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACH,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,cAAc,EACd,YAAY,EACZ,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,eAAe,EACf,OAAO,GACV,MAAM,WAAW,CAAC;AAKnB,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,UAAU,GAAG,cAAc,GAAG,cAAc,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;AACjG,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,M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ACtG,CAAC;AACN,CAAC;AAED,OAAO,EACH,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EAEf,aAAa,EACb,qBAAqB,GACxB,CAAC","sourcesContent":["import { type ExternalObject, type Handle, read } from \"@gtkx/native\";\nimport { bind } from \"./bind.js\";\nimport { biguint64T, booleanT, stringT, uint32T, voidT } from \"./descriptors.js\";\nimport { LIB, PARAM_T, VALUE_T } from \"./library.js\";\nimport { getInstanceType } from \"./registry.js\";\nimport {\n getStrvType,\n isTypedClass,\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_OBJECT,\n TYPE_PARAM,\n TYPE_POINTER,\n TYPE_STRING,\n TYPE_UCHAR,\n TYPE_UINT,\n TYPE_UINT64,\n TYPE_ULONG,\n TYPE_VARIANT,\n typeFundamental,\n typeIsA,\n} from \"./type.js\";\n\ntype ValueGuard = (value: unknown) => boolean;\ntype ParamLayout = { flags: number; valueType: bigint };\n\nconst PARAM_READABLE = 1;\nconst PARAM_WRITABLE = 2;\nconst PARAM_CONSTRUCT_ONLY = 8;\nconst PARAM_LAX_VALIDATION = 16;\nconst READ_FLAGS = PARAM_READABLE | PARAM_WRITABLE | PARAM_CONSTRUCT_ONLY | PARAM_LAX_VALIDATION;\nconst FLAGS_BYTE_OFFSET = 16;\nconst VALUE_TYPE_BYTE_OFFSET = 24;\nconst LAYOUT_PROBE_NAME = \"gtkx-param-layout\";\nconst INT8_MINIMUM = -128;\nconst INT8_MAXIMUM = 127;\nconst UINT8_MAXIMUM = 255;\nconst INT32_MINIMUM = -2_147_483_648;\nconst INT32_MAXIMUM = 2_147_483_647;\nconst UINT32_MAXIMUM = 4_294_967_295;\nconst INT64_MINIMUM = -(2n ** 63n);\nconst INT64_MAXIMUM = 2n ** 63n - 1n;\nconst UINT64_MAXIMUM = 2n ** 64n - 1n;\n\nconst WRAPPED_FUNDAMENTALS: Set<bigint> = new Set([\n TYPE_BOXED,\n TYPE_INTERFACE,\n TYPE_OBJECT,\n TYPE_PARAM,\n TYPE_VARIANT,\n]);\n\nconst isWideUnsignedValue: ValueGuard = wideIntegerGuardFor(0n, UINT64_MAXIMUM);\n\nconst SCALAR_GUARDS: Map<bigint, ValueGuard> = new Map([\n [TYPE_BOOLEAN, isBooleanValue],\n [TYPE_STRING, isStringValue],\n [TYPE_CHAR, integerGuardFor(INT8_MINIMUM, INT8_MAXIMUM)],\n [TYPE_UCHAR, integerGuardFor(0, UINT8_MAXIMUM)],\n [TYPE_INT, integerGuardFor(INT32_MINIMUM, INT32_MAXIMUM)],\n [TYPE_UINT, integerGuardFor(0, UINT32_MAXIMUM)],\n [TYPE_ENUM, integerGuardFor(INT32_MINIMUM, INT32_MAXIMUM)],\n [TYPE_FLAGS, integerGuardFor(0, UINT32_MAXIMUM)],\n [TYPE_LONG, wideIntegerGuardFor(INT64_MINIMUM, INT64_MAXIMUM)],\n [TYPE_ULONG, isWideUnsignedValue],\n [TYPE_INT64, wideIntegerGuardFor(INT64_MINIMUM, INT64_MAXIMUM)],\n [TYPE_UINT64, isWideUnsignedValue],\n [TYPE_FLOAT, isNumberValue],\n [TYPE_DOUBLE, isNumberValue],\n [TYPE_POINTER, isNullValue],\n]);\n\nconst layout = { wasChecked: false };\nconst paramValueValidate = bind(LIB, \"g_param_value_validate\", [PARAM_T, VALUE_T], booleanT);\nconst paramSpecUnref = bind(LIB, \"g_param_spec_unref\", [PARAM_T], voidT);\nconst paramSpecRefSink = bind(LIB, \"g_param_spec_ref_sink\", [PARAM_T], PARAM_T);\n\nconst newParamSpecBoolean = bind(\n LIB,\n \"g_param_spec_boolean\",\n [stringT(\"borrowed\"), stringT(\"borrowed\"), stringT(\"borrowed\"), booleanT, uint32T],\n PARAM_T,\n);\n\nconst getParamFlags = (pspec: ExternalObject<Handle>): number => read(pspec, uint32T, FLAGS_BYTE_OFFSET) as number;\n\nconst getParamValueType = (pspec: ExternalObject<Handle>): bigint =>\n read(pspec, biguint64T, VALUE_TYPE_BYTE_OFFSET) as bigint;\n\nconst isParamWritable = (flags: number): boolean => (flags & PARAM_WRITABLE) !== 0;\nconst isParamConstructOnly = (flags: number): boolean => (flags & PARAM_CONSTRUCT_ONLY) !== 0;\nconst isParamLaxlyValidated = (flags: number): boolean => (flags & PARAM_LAX_VALIDATION) !== 0;\n\nconst wasParamValueModified = (pspec: ExternalObject<Handle>, value: ExternalObject<Handle>): boolean =>\n paramValueValidate(pspec, value) as boolean;\n\nfunction isBooleanValue(value: unknown): boolean {\n return typeof value === \"boolean\";\n}\n\nfunction isStringValue(value: unknown): boolean {\n return value == null || typeof value === \"string\";\n}\n\nfunction isStrvValue(value: unknown): boolean {\n return value == null || (Array.isArray(value) && value.every((item) => typeof item === \"string\"));\n}\n\nfunction isNumberValue(value: unknown): boolean {\n return typeof value === \"number\";\n}\n\nfunction isAnyValue(): boolean {\n return true;\n}\n\nfunction isNullValue(value: unknown): boolean {\n return value == null;\n}\n\nfunction integerGuardFor(minimum: number, maximum: number): ValueGuard {\n return (value) => Number.isSafeInteger(value) && (value as number) >= minimum && (value as number) <= maximum;\n}\n\nfunction toWideInteger(value: unknown): bigint | undefined {\n if (typeof value === \"bigint\") {\n return value;\n }\n\n return Number.isSafeInteger(value) ? BigInt(value as number) : undefined;\n}\n\nfunction wideIntegerGuardFor(minimum: bigint, maximum: bigint): ValueGuard {\n return (value) => {\n const wide = toWideInteger(value);\n\n return wide !== undefined && wide >= minimum && wide <= maximum;\n };\n}\n\nfunction resolveGtype(value: unknown): bigint {\n const instanceType = getInstanceType(value as object);\n\n if (instanceType !== TYPE_INVALID) {\n return instanceType;\n }\n\n return isTypedClass(value) ? value.__type__ : TYPE_INVALID;\n}\n\nfunction wrappedGuardFor(valueType: bigint): ValueGuard {\n return (value) => value == null || typeIsA(resolveGtype(value), valueType);\n}\n\nfunction exactGuardFor(valueType: bigint): ValueGuard | undefined {\n if (valueType === TYPE_GTYPE) {\n return isWideUnsignedValue;\n }\n\n return valueType === getStrvType() ? isStrvValue : undefined;\n}\n\nfunction valueGuardFor(valueType: bigint): ValueGuard {\n assertParamLayout();\n const exact = exactGuardFor(valueType);\n\n if (exact !== undefined) {\n return exact;\n }\n\n const fundamental = typeFundamental(valueType);\n\n if (WRAPPED_FUNDAMENTALS.has(fundamental)) {\n return wrappedGuardFor(valueType);\n }\n\n return SCALAR_GUARDS.get(fundamental) ?? isAnyValue;\n}\n\nfunction readProbeLayout(flags: number): ParamLayout {\n const probe = newParamSpecBoolean(LAYOUT_PROBE_NAME, null, null, false, flags) as ExternalObject<Handle>;\n paramSpecRefSink(probe);\n\n try {\n return { flags: getParamFlags(probe), valueType: getParamValueType(probe) };\n } finally {\n paramSpecUnref(probe);\n }\n}\n\nfunction isLayoutIntact(flags: number): boolean {\n const layout = readProbeLayout(flags);\n\n return (layout.flags & READ_FLAGS) === flags && layout.valueType === TYPE_BOOLEAN;\n}\n\nfunction assertParamLayout(): void {\n if (layout.wasChecked) {\n return;\n }\n\n layout.wasChecked = true;\n const readWrite = PARAM_READABLE | PARAM_WRITABLE;\n\n if (isLayoutIntact(readWrite) && isLayoutIntact(readWrite | PARAM_CONSTRUCT_ONLY | PARAM_LAX_VALIDATION)) {\n return;\n }\n\n throw new Error(\n \"GParamSpec does not match the memory layout this build reads a property's flags and value type at\",\n );\n}\n\nexport {\n getParamFlags,\n getParamValueType,\n isParamConstructOnly,\n isParamLaxlyValidated,\n isParamWritable,\n type ValueGuard,\n valueGuardFor,\n wasParamValueModified,\n};\n"]}
1
+ {"version":3,"file":"param-spec.js","sourceRoot":"","sources":["../src/param-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,IAAI,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,WA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AS,GAAG,cAAc,GAAG,cAAc,CAAC;IAElD,IAAI,cAAc,CAAC,SAAS,CAAC,IAAI,cAAc,CAAC,SAAS,GAAG,oBAAoB,GAAG,oBAAoB,CAAC,EAAE,CAAC;QACvG,OAAO;IACX,CAAC;IAED,MAAM,IAAI,KAAK,CACX,mGAAmG,CACtG,CAAC;AACN,CAAC;AAED,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,cAAc,EAEd,aAAa,EACb,qBAAqB,GACxB,CAAC","sourcesContent":["import { type ExternalObject, type Handle, read } from \"@gtkx/native\";\nimport { bind } from \"./bind.js\";\nimport { biguint64T, booleanT, stringT, uint32T, voidT } from \"./descriptors.js\";\nimport { LIB, PARAM_T, VALUE_T } from \"./library.js\";\nimport { getHandle, getInstanceType } from \"./registry.js\";\nimport {\n getStrvType,\n isTypedClass,\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_OBJECT,\n TYPE_PARAM,\n TYPE_POINTER,\n TYPE_STRING,\n TYPE_UCHAR,\n TYPE_UINT,\n TYPE_UINT64,\n TYPE_ULONG,\n TYPE_VARIANT,\n typeFundamental,\n typeIsA,\n} from \"./type.js\";\n\ntype ValueGuard = (value: unknown) => boolean;\ntype ParamLayout = { flags: number; valueType: bigint; ownerType: bigint };\n\nconst PARAM_READABLE = 1;\nconst PARAM_WRITABLE = 2;\nconst PARAM_CONSTRUCT_ONLY = 8;\nconst PARAM_LAX_VALIDATION = 16;\nconst PARAM_EXPLICIT_NOTIFY = 1 << 30;\nconst READ_FLAGS = PARAM_READABLE | PARAM_WRITABLE | PARAM_CONSTRUCT_ONLY | PARAM_LAX_VALIDATION;\nconst FLAGS_BYTE_OFFSET = 16;\nconst VALUE_TYPE_BYTE_OFFSET = 24;\nconst OWNER_TYPE_BYTE_OFFSET = 32;\nconst LAYOUT_PROBE_NAME = \"gtkx-param-layout\";\nconst INT8_MINIMUM = -128;\nconst INT8_MAXIMUM = 127;\nconst UINT8_MAXIMUM = 255;\nconst INT32_MINIMUM = -2_147_483_648;\nconst INT32_MAXIMUM = 2_147_483_647;\nconst UINT32_MAXIMUM = 4_294_967_295;\nconst INT64_MINIMUM: bigint = -(2n ** 63n);\nconst INT64_MAXIMUM: bigint = 2n ** 63n - 1n;\nconst UINT64_MAXIMUM: bigint = 2n ** 64n - 1n;\n\nconst WRAPPED_FUNDAMENTALS: Set<bigint> = new Set([\n TYPE_BOXED,\n TYPE_INTERFACE,\n TYPE_OBJECT,\n TYPE_PARAM,\n TYPE_VARIANT,\n]);\n\nconst isWideUnsignedValue: ValueGuard = wideIntegerGuardFor(0n, UINT64_MAXIMUM);\nconst MAX_SAFE: number = Number.MAX_SAFE_INTEGER;\n\nconst WHOLE_NUMBER_RANGES: Map<bigint, [minimum: number, maximum: number]> = new Map([\n [TYPE_CHAR, [INT8_MINIMUM, INT8_MAXIMUM]],\n [TYPE_UCHAR, [0, UINT8_MAXIMUM]],\n [TYPE_INT, [INT32_MINIMUM, INT32_MAXIMUM]],\n [TYPE_UINT, [0, UINT32_MAXIMUM]],\n [TYPE_ENUM, [INT32_MINIMUM, INT32_MAXIMUM]],\n [TYPE_FLAGS, [0, UINT32_MAXIMUM]],\n [TYPE_LONG, [-MAX_SAFE, MAX_SAFE]],\n [TYPE_ULONG, [0, MAX_SAFE]],\n [TYPE_INT64, [-MAX_SAFE, MAX_SAFE]],\n [TYPE_UINT64, [0, MAX_SAFE]],\n]);\n\nconst SCALAR_GUARDS: Map<bigint, ValueGuard> = new Map([\n [TYPE_BOOLEAN, isBooleanValue],\n [TYPE_STRING, isStringValue],\n [TYPE_CHAR, integerGuardFor(INT8_MINIMUM, INT8_MAXIMUM)],\n [TYPE_UCHAR, integerGuardFor(0, UINT8_MAXIMUM)],\n [TYPE_INT, integerGuardFor(INT32_MINIMUM, INT32_MAXIMUM)],\n [TYPE_UINT, integerGuardFor(0, UINT32_MAXIMUM)],\n [TYPE_ENUM, integerGuardFor(INT32_MINIMUM, INT32_MAXIMUM)],\n [TYPE_FLAGS, integerGuardFor(0, UINT32_MAXIMUM)],\n [TYPE_LONG, wideIntegerGuardFor(INT64_MINIMUM, INT64_MAXIMUM)],\n [TYPE_ULONG, isWideUnsignedValue],\n [TYPE_INT64, wideIntegerGuardFor(INT64_MINIMUM, INT64_MAXIMUM)],\n [TYPE_UINT64, isWideUnsignedValue],\n [TYPE_FLOAT, isNumberValue],\n [TYPE_DOUBLE, isNumberValue],\n [TYPE_POINTER, isNullValue],\n]);\n\nconst layout = { wasChecked: false };\nconst paramValueValidate = bind(LIB, \"g_param_value_validate\", [PARAM_T, VALUE_T], booleanT);\nconst paramSpecUnref = bind(LIB, \"g_param_spec_unref\", [PARAM_T], voidT);\nconst paramSpecRefSink = bind(LIB, \"g_param_spec_ref_sink\", [PARAM_T], PARAM_T);\n\nconst newParamSpecBoolean = bind(\n LIB,\n \"g_param_spec_boolean\",\n [stringT(\"borrowed\"), stringT(\"borrowed\"), stringT(\"borrowed\"), booleanT, uint32T],\n PARAM_T,\n);\n\nconst getParamFlags = (pspec: ExternalObject<Handle>): number => read(pspec, uint32T, FLAGS_BYTE_OFFSET) as number;\n\nconst getParamValueType = (pspec: ExternalObject<Handle>): bigint =>\n read(pspec, biguint64T, VALUE_TYPE_BYTE_OFFSET) as bigint;\n\nconst getParamOwnerType = (pspec: ExternalObject<Handle>): bigint =>\n read(pspec, biguint64T, OWNER_TYPE_BYTE_OFFSET) as bigint;\n\n/**\n * Reads the `GParamFlags` bitfield of a `GObject.ParamSpec`.\n *\n * @param spec The param spec wrapper to read.\n * @returns The spec's flags.\n */\nconst getParamSpecFlags = (spec: object): number => {\n assertParamLayout();\n\n return getParamFlags(getHandle(spec));\n};\n\n/**\n * Reads the GType of the values a `GObject.ParamSpec` describes.\n *\n * @param spec The param spec wrapper to read.\n * @returns The GType of the spec's values.\n */\nconst getParamSpecValueType = (spec: object): bigint => {\n assertParamLayout();\n\n return getParamValueType(getHandle(spec));\n};\n\n/**\n * Reads the GType a `GObject.ParamSpec` is installed on.\n *\n * @param spec The param spec wrapper to read.\n * @returns The owning GType, or `TYPE_INVALID` while the spec is not installed on any type.\n */\nconst getParamSpecOwnerType = (spec: object): bigint => {\n assertParamLayout();\n\n return getParamOwnerType(getHandle(spec));\n};\n\nconst isParamWritable = (flags: number): boolean => (flags & PARAM_WRITABLE) !== 0;\nconst isParamConstructOnly = (flags: number): boolean => (flags & PARAM_CONSTRUCT_ONLY) !== 0;\nconst isParamLaxlyValidated = (flags: number): boolean => (flags & PARAM_LAX_VALIDATION) !== 0;\nconst isParamExplicitlyNotified = (flags: number): boolean => (flags & PARAM_EXPLICIT_NOTIFY) !== 0;\n\nconst wasParamValueModified = (pspec: ExternalObject<Handle>, value: ExternalObject<Handle>): boolean =>\n paramValueValidate(pspec, value) as boolean;\n\nfunction isBooleanValue(value: unknown): boolean {\n return typeof value === \"boolean\";\n}\n\nfunction isStringValue(value: unknown): boolean {\n return value == null || typeof value === \"string\";\n}\n\nfunction isStringArray(value: unknown[]): boolean {\n for (const item of value) {\n if (typeof item !== \"string\") {\n return false;\n }\n }\n\n return true;\n}\n\nfunction isStrvValue(value: unknown): boolean {\n return value == null || (Array.isArray(value) && isStringArray(value));\n}\n\nfunction isNumberValue(value: unknown): boolean {\n return typeof value === \"number\";\n}\n\nfunction isAnyValue(): boolean {\n return true;\n}\n\nfunction isNullValue(value: unknown): boolean {\n return value == null;\n}\n\nfunction integerGuardFor(minimum: number, maximum: number): ValueGuard {\n return (value) => Number.isSafeInteger(value) && (value as number) >= minimum && (value as number) <= maximum;\n}\n\nfunction toWideInteger(value: unknown): bigint | undefined {\n if (typeof value === \"bigint\") {\n return value;\n }\n\n return Number.isSafeInteger(value) ? BigInt(value as number) : undefined;\n}\n\nfunction wideIntegerGuardFor(minimum: bigint, maximum: bigint): ValueGuard {\n return (value) => {\n const wide = toWideInteger(value);\n\n return wide !== undefined && wide >= minimum && wide <= maximum;\n };\n}\n\nfunction resolveGtype(value: unknown): bigint {\n const instanceType = getInstanceType(value as object);\n\n if (instanceType !== TYPE_INVALID) {\n return instanceType;\n }\n\n return isTypedClass(value) ? value.__type__ : TYPE_INVALID;\n}\n\nfunction wrappedGuardFor(valueType: bigint): ValueGuard {\n return (value) => value == null || typeIsA(resolveGtype(value), valueType);\n}\n\nfunction exactGuardFor(valueType: bigint): ValueGuard | undefined {\n if (valueType === TYPE_GTYPE) {\n return isWideUnsignedValue;\n }\n\n return valueType === getStrvType() ? isStrvValue : undefined;\n}\n\nfunction valueGuardFor(valueType: bigint): ValueGuard {\n assertParamLayout();\n const exact = exactGuardFor(valueType);\n\n if (exact !== undefined) {\n return exact;\n }\n\n const fundamental = typeFundamental(valueType);\n\n if (WRAPPED_FUNDAMENTALS.has(fundamental)) {\n return wrappedGuardFor(valueType);\n }\n\n return SCALAR_GUARDS.get(fundamental) ?? isAnyValue;\n}\n\nfunction readProbeLayout(flags: number): ParamLayout {\n const probe = newParamSpecBoolean(LAYOUT_PROBE_NAME, null, null, false, flags) as ExternalObject<Handle>;\n paramSpecRefSink(probe);\n\n try {\n return {\n flags: getParamFlags(probe),\n valueType: getParamValueType(probe),\n ownerType: getParamOwnerType(probe),\n };\n } finally {\n paramSpecUnref(probe);\n }\n}\n\nfunction isLayoutIntact(flags: number): boolean {\n const layout = readProbeLayout(flags);\n\n return (\n (layout.flags & READ_FLAGS) === flags &&\n layout.valueType === TYPE_BOOLEAN &&\n layout.ownerType === TYPE_INVALID\n );\n}\n\nfunction assertParamLayout(): void {\n if (layout.wasChecked) {\n return;\n }\n\n layout.wasChecked = true;\n const readWrite = PARAM_READABLE | PARAM_WRITABLE;\n\n if (isLayoutIntact(readWrite) && isLayoutIntact(readWrite | PARAM_CONSTRUCT_ONLY | PARAM_LAX_VALIDATION)) {\n return;\n }\n\n throw new Error(\n \"GParamSpec does not match the memory layout this build reads a property's flags and value type at\",\n );\n}\n\nexport {\n WHOLE_NUMBER_RANGES,\n getParamFlags,\n getParamSpecFlags,\n getParamSpecOwnerType,\n getParamSpecValueType,\n getParamValueType,\n INT32_MAXIMUM,\n INT32_MINIMUM,\n INT64_MAXIMUM,\n INT64_MINIMUM,\n isParamConstructOnly,\n isStringArray,\n isParamExplicitlyNotified,\n isParamLaxlyValidated,\n isParamWritable,\n resolveGtype,\n UINT64_MAXIMUM,\n type ValueGuard,\n valueGuardFor,\n wasParamValueModified,\n};\n"]}
@@ -3,6 +3,18 @@
3
3
  * the operation failed.
4
4
  */
5
5
  type FinishResult<R extends object, T> = (result: R) => T;
6
+ /** A finish result with its leading success boolean dropped: bare when one value remains, a tuple otherwise. */
7
+ type TrimmedFinish<T> = T extends readonly [boolean, infer Only] ? Only : T extends readonly [boolean, ...infer Rest] ? Rest : never;
8
+ /**
9
+ * Wraps a finish function whose result leads with the success boolean of a throwing C call,
10
+ * dropping that boolean: failure already surfaces as a thrown error, so the boolean is always
11
+ * `true`. A single remaining value is handed back bare, several stay a tuple. The finish result
12
+ * must carry at least one value beyond the boolean; a boolean-only finish needs no trimming.
13
+ *
14
+ * @param finish Extracts the boolean-led result from the async result passed to the completion callback.
15
+ * @returns A finish function resolving to the result without its leading boolean.
16
+ */
17
+ declare const trimFinish: <R extends object, T extends readonly [boolean, unknown, ...unknown[]]>(finish: FinishResult<R, T>) => FinishResult<R, TrimmedFinish<T>>;
6
18
  /**
7
19
  * Wraps a GIO-style asynchronous function that takes a completion callback into a
8
20
  * promise, invoking the finish function to extract the result. Outside production,
@@ -15,5 +27,5 @@ type FinishResult<R extends object, T> = (result: R) => T;
15
27
  * @returns A promise resolving to the finished result, or rejecting if `finish` throws.
16
28
  */
17
29
  declare const promisify: <R extends object, T>(asyncFn: (...args: unknown[]) => void, finish: FinishResult<R, T>, cancellable: object | null | undefined, ...leading: unknown[]) => Promise<T>;
18
- export { promisify };
30
+ export { promisify, trimFinish };
19
31
  //# sourceMappingURL=promisify.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promisify.d.ts","sourceRoot":"","sources":["../src/promisify.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;AAgC1D;;;;;;;;;;GAUG;AACH,QAAA,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,EAClC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,EACrC,QAAQ,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,aAAa,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,GAAG,SAAS,OAAO,EAAE,KACtB,OAAO,CAAC,CAAC,CAUN,CAAC;AAEP,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"promisify.d.ts","sourceRoot":"","sources":["../src/promisify.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;AAS1D,gHAAgH;AAChH,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,GAC1D,IAAI,GACJ,CAAC,SAAS,SAAS,CAAC,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,GACvC,IAAI,GACJ,KAAK,CAAC;AAyBhB;;;;;;;;GAQG;AACH,QAAA,MAAM,UAAU,GACX,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,EAClE,QAAQ,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,KAC3B,YAAY,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAK9B,CAAC;AAEV;;;;;;;;;;GAUG;AACH,QAAA,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,EAClC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,EACrC,QAAQ,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,aAAa,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,GAAG,SAAS,OAAO,EAAE,KACtB,OAAO,CAAC,CAAC,CAUN,CAAC;AAEP,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC"}
package/dist/promisify.js CHANGED
@@ -18,6 +18,19 @@ const settle = (settlement, asyncResult) => {
18
18
  reject(error instanceof Error ? error : new Error(String(error)));
19
19
  }
20
20
  };
21
+ /**
22
+ * Wraps a finish function whose result leads with the success boolean of a throwing C call,
23
+ * dropping that boolean: failure already surfaces as a thrown error, so the boolean is always
24
+ * `true`. A single remaining value is handed back bare, several stay a tuple. The finish result
25
+ * must carry at least one value beyond the boolean; a boolean-only finish needs no trimming.
26
+ *
27
+ * @param finish Extracts the boolean-led result from the async result passed to the completion callback.
28
+ * @returns A finish function resolving to the result without its leading boolean.
29
+ */
30
+ const trimFinish = (finish) => (result) => {
31
+ const [, ...rest] = finish(result);
32
+ return (rest.length === 1 ? rest[0] : rest);
33
+ };
21
34
  /**
22
35
  * Wraps a GIO-style asynchronous function that takes a completion callback into a
23
36
  * promise, invoking the finish function to extract the result. Outside production,
@@ -36,5 +49,5 @@ const promisify = (asyncFn, finish, cancellable, ...leading) => new Promise((res
36
49
  settle({ finish, creationStack, resolve, reject }, asyncResult);
37
50
  });
38
51
  });
39
- export { promisify };
52
+ export { promisify, trimFinish };
40
53
  //# sourceMappingURL=promisify.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"promisify.js","sourceRoot":"","sources":["../src/promisify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAe1C,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAE,aAAgC,EAAQ,EAAE;IACnF,IAAI,aAAa,KAAK,SAAS,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO;IACX,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO;IACX,CAAC;IAED,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAsB,UAA4B,EAAE,WAAmB,EAAQ,EAAE;IAC5F,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAE9D,IAAI,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,WAAgB,CAAC,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,mBAAmB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QAC1C,MAAM,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC;AACL,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,SAAS,GAAG,CACd,OAAqC,EACrC,MAA0B,EAC1B,WAAsC,EACtC,GAAG,OAAkB,EACX,EAAE,CACZ,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC/B,MAAM,aAAa,GACf,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAEvG,MAAM,iBAAiB,GAAG,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE9E,OAAO,CAAC,GAAG,OAAO,EAAE,iBAAiB,EAAE,CAAC,OAAsB,EAAE,WAAmB,EAAE,EAAE;QACnF,MAAM,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEP,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { getHandle } from \"./registry.js\";\n\n/**\n * Extracts the value of a completed asynchronous operation from its `GAsyncResult`, throwing when\n * the operation failed.\n */\ntype FinishResult<R extends object, T> = (result: R) => T;\n\ntype Settlement<R extends object, T> = {\n finish: FinishResult<R, T>;\n creationStack: Error | undefined;\n resolve: (value: T) => void;\n reject: (reason: Error) => void;\n};\n\nconst attachCreationStack = (error: unknown, creationStack: Error | undefined): void => {\n if (creationStack === undefined || !(error instanceof Error)) {\n return;\n }\n\n if (error.cause !== undefined || !Object.isExtensible(error)) {\n return;\n }\n\n error.cause = creationStack;\n};\n\nconst settle = <R extends object, T>(settlement: Settlement<R, T>, asyncResult: object): void => {\n const { finish, creationStack, resolve, reject } = settlement;\n\n try {\n resolve(finish(asyncResult as R));\n } catch (error) {\n attachCreationStack(error, creationStack);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n};\n\n/**\n * Wraps a GIO-style asynchronous function that takes a completion callback into a\n * promise, invoking the finish function to extract the result. Outside production,\n * the call site's stack is captured and attached as the rejection error's cause.\n *\n * @param asyncFn The async function, called with the leading arguments, the cancellable, and a completion callback.\n * @param finish Extracts the result from the async result passed to the completion callback.\n * @param cancellable A cancellable object, or null/undefined for none.\n * @param leading Arguments passed to `asyncFn` before the cancellable and callback.\n * @returns A promise resolving to the finished result, or rejecting if `finish` throws.\n */\nconst promisify = <R extends object, T>(\n asyncFn: (...args: unknown[]) => void,\n finish: FinishResult<R, T>,\n cancellable: object | null | undefined,\n ...leading: unknown[]\n): Promise<T> =>\n new Promise<T>((resolve, reject) => {\n const creationStack =\n process.env.NODE_ENV === \"production\" ? undefined : new Error(\"GTKX async operation started here\");\n\n const cancellableHandle = cancellable == null ? null : getHandle(cancellable);\n\n asyncFn(...leading, cancellableHandle, (_source: object | null, asyncResult: object) => {\n settle({ finish, creationStack, resolve, reject }, asyncResult);\n });\n });\n\nexport { promisify };\n"]}
1
+ {"version":3,"file":"promisify.js","sourceRoot":"","sources":["../src/promisify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAsB1C,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAE,aAAgC,EAAQ,EAAE;IACnF,IAAI,aAAa,KAAK,SAAS,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO;IACX,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO;IACX,CAAC;IAED,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAsB,UAA4B,EAAE,WAAmB,EAAQ,EAAE;IAC5F,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAE9D,IAAI,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,WAAgB,CAAC,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,mBAAmB,CAAC,KAAK,EAAE,aAAa,CAAC,CA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Handle } from \"./registry.js\";\n\n/**\n * Extracts the value of a completed asynchronous operation from its `GAsyncResult`, throwing when\n * the operation failed.\n */\ntype FinishResult<R extends object, T> = (result: R) => T;\n\ntype Settlement<R extends object, T> = {\n finish: FinishResult<R, T>;\n creationStack: Error | undefined;\n resolve: (value: T) => void;\n reject: (reason: Error) => void;\n};\n\n/** A finish result with its leading success boolean dropped: bare when one value remains, a tuple otherwise. */\ntype TrimmedFinish<T> = T extends readonly [boolean, infer Only]\n ? Only\n : T extends readonly [boolean, ...infer Rest]\n ? Rest\n : never;\n\nconst attachCreationStack = (error: unknown, creationStack: Error | undefined): void => {\n if (creationStack === undefined || !(error instanceof Error)) {\n return;\n }\n\n if (error.cause !== undefined || !Object.isExtensible(error)) {\n return;\n }\n\n error.cause = creationStack;\n};\n\nconst settle = <R extends object, T>(settlement: Settlement<R, T>, asyncResult: object): void => {\n const { finish, creationStack, resolve, reject } = settlement;\n\n try {\n resolve(finish(asyncResult as R));\n } catch (error) {\n attachCreationStack(error, creationStack);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n};\n\n/**\n * Wraps a finish function whose result leads with the success boolean of a throwing C call,\n * dropping that boolean: failure already surfaces as a thrown error, so the boolean is always\n * `true`. A single remaining value is handed back bare, several stay a tuple. The finish result\n * must carry at least one value beyond the boolean; a boolean-only finish needs no trimming.\n *\n * @param finish Extracts the boolean-led result from the async result passed to the completion callback.\n * @returns A finish function resolving to the result without its leading boolean.\n */\nconst trimFinish =\n <R extends object, T extends readonly [boolean, unknown, ...unknown[]]>(\n finish: FinishResult<R, T>,\n ): FinishResult<R, TrimmedFinish<T>> =>\n (result: R): TrimmedFinish<T> => {\n const [, ...rest] = finish(result);\n\n return (rest.length === 1 ? rest[0] : rest) as TrimmedFinish<T>;\n };\n\n/**\n * Wraps a GIO-style asynchronous function that takes a completion callback into a\n * promise, invoking the finish function to extract the result. Outside production,\n * the call site's stack is captured and attached as the rejection error's cause.\n *\n * @param asyncFn The async function, called with the leading arguments, the cancellable, and a completion callback.\n * @param finish Extracts the result from the async result passed to the completion callback.\n * @param cancellable A cancellable object, or null/undefined for none.\n * @param leading Arguments passed to `asyncFn` before the cancellable and callback.\n * @returns A promise resolving to the finished result, or rejecting if `finish` throws.\n */\nconst promisify = <R extends object, T>(\n asyncFn: (...args: unknown[]) => void,\n finish: FinishResult<R, T>,\n cancellable: object | null | undefined,\n ...leading: unknown[]\n): Promise<T> =>\n new Promise<T>((resolve, reject) => {\n const creationStack =\n process.env.NODE_ENV === \"production\" ? undefined : new Error(\"GTKX async operation started here\");\n\n const cancellableHandle = cancellable == null ? null : getHandle(cancellable);\n\n asyncFn(...leading, cancellableHandle, (_source: object | null, asyncResult: object) => {\n settle({ finish, creationStack, resolve, reject }, asyncResult);\n });\n });\n\nexport { promisify, trimFinish };\n"]}
@@ -38,10 +38,37 @@ type ConstructProperty = {
38
38
  };
39
39
  declare const GET_PROPERTY_VFUNC = "vfuncGetProperty";
40
40
  declare const SET_PROPERTY_VFUNC = "vfuncSetProperty";
41
+ /**
42
+ * Creates the handle of a `GParamSpec` that redirects to the property `source` declares under
43
+ * `name` — the equivalent of `g_param_spec_override`, which introspection does not expose.
44
+ *
45
+ * Throws when `source` is neither a GType nor a registered class or interface, and when it
46
+ * declares no property under `name`.
47
+ *
48
+ * @param name Canonical name of the property to override.
49
+ * @param source The GType, wrapper class or interface declaring the property.
50
+ * @returns Handle of the override spec.
51
+ */
52
+ declare const newParamSpecOverride: (name: string, source: bigint | AnyClass) => ExternalObject<Handle>;
53
+ declare function coercePropertyValue(gtype: bigint, propertyName: string, value: unknown): unknown;
54
+ /**
55
+ * Fits a number to what a GObject property accepts, the way an animation writing a value on every
56
+ * frame needs: a fractional number headed for a property that holds whole numbers, such as a
57
+ * `gint`, an enum, or flags, is truncated toward zero, and a number outside the range the
58
+ * property's `GObject.ParamSpec` allows is clamped to it, so the write that follows never trips
59
+ * GObject's range check. Anything that is not a finite number, a number the property cannot hold
60
+ * at all, and a name the object installs no property under come back unchanged.
61
+ *
62
+ * @param obj The object the value is about to be written to.
63
+ * @param propertyName The property name, dashed or camelCased.
64
+ * @param value The value about to be written.
65
+ * @returns The value as the property accepts it.
66
+ */
67
+ declare function coerceObjectProperty(obj: object, propertyName: string, value: unknown): unknown;
41
68
  declare function constructPropertyFor(gtype: bigint, name: string, value: unknown, wrapper: object): ConstructProperty | undefined;
42
69
  declare function makeGetProperty(dispatch: PropertyDispatch): (this: object, propertyId: number, value: object, pspec: PropertySpec) => void;
43
70
  declare function makeSetProperty(dispatch: PropertyDispatch): (this: object, propertyId: number, value: object, pspec: PropertySpec) => void;
44
71
  declare function buildPropertyDispatch(source: PropertyDispatchSource): PropertyDispatch;
45
72
  declare function toNativeProperties(properties: Record<string, PropertySpec>): RegisterClassProperty[];
46
- export { buildPropertyDispatch, constructPropertyFor, GET_PROPERTY_VFUNC, makeGetProperty, makeSetProperty, SET_PROPERTY_VFUNC, toNativeProperties, type ConstructProperty, type PropertyDispatch, type PropertySpec, };
73
+ export { buildPropertyDispatch, coerceObjectProperty, coercePropertyValue, constructPropertyFor, GET_PROPERTY_VFUNC, makeGetProperty, makeSetProperty, newParamSpecOverride, SET_PROPERTY_VFUNC, toNativeProperties, type ConstructProperty, type PropertyDispatch, type PropertySpec, };
47
74
  //# sourceMappingURL=properties.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../src/properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,OAAO,EAMH,KAAK,UAAU,EAGlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAwD,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE7G,OAAO,EAGH,KAAK,aAAa,EAElB,KAAK,WAAW,EAEnB,MAAM,YAAY,CAAC;AAEpB,KA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