gnim 1.7.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dbus.ts CHANGED
@@ -620,9 +620,9 @@ export function method<const InArgs extends Array<DBusType>, const OutArgs exten
620
620
  inArgs: InArgs,
621
621
  outArgs: OutArgs,
622
622
  ): (
623
- method: (this: Service, ...args: InferVariantTypes<InArgs>) => InferVariantTypes<OutArgs>,
623
+ method: (this: Service, ...args: any[]) => InferVariantTypes<OutArgs>,
624
624
  ctx: ClassMethodDecoratorContext<Service, typeof method>,
625
- ) => void
625
+ ) => (this: Service, ...args: InferVariantTypes<InArgs>) => any
626
626
 
627
627
  /**
628
628
  * Registers a method.
@@ -633,9 +633,9 @@ export function method<const InArgs extends Array<DBusType>, const OutArgs exten
633
633
  export function method<const InArgs extends Array<DBusType>>(
634
634
  ...inArgs: InArgs
635
635
  ): (
636
- method: (this: Service, ...args: InferVariantTypes<InArgs>) => void,
636
+ method: (this: Service, ...args: any[]) => void,
637
637
  ctx: ClassMethodDecoratorContext<Service, typeof method>,
638
- ) => void
638
+ ) => (this: Service, ...args: InferVariantTypes<InArgs>) => void
639
639
 
640
640
  export function method<const InArgs extends Array<DBusType>, const OutArgs extends Array<DBusType>>(
641
641
  ...args: InArgs | [inArgs: InArgs, outArgs?: OutArgs]
@@ -646,10 +646,10 @@ export function method<const InArgs extends Array<DBusType>, const OutArgs exten
646
646
  ...args: InferVariantTypes<InArgs>
647
647
  ) => InferVariantTypes<OutArgs> | void,
648
648
  ctx: ClassMethodDecoratorContext<Service, typeof method>,
649
- ): typeof method {
649
+ ): (this: Service, ...args: InferVariantTypes<InArgs>) => any {
650
650
  const name = installMethod(args, method, ctx)
651
651
 
652
- return function (...args: InferVariantTypes<InArgs>) {
652
+ return function (...args) {
653
653
  if (this[internals].proxy) {
654
654
  const value = this[remoteMethod](name, args)
655
655
  return value.deepUnpack<InferVariantTypes<OutArgs>>()
@@ -673,12 +673,9 @@ export function methodAsync<
673
673
  inArgs: InArgs,
674
674
  outArgs: OutArgs,
675
675
  ): (
676
- method: (
677
- this: Service,
678
- ...args: InferVariantTypes<InArgs>
679
- ) => Promise<InferVariantTypes<OutArgs>>,
676
+ method: (this: Service, ...args: any[]) => Promise<InferVariantTypes<OutArgs>>,
680
677
  ctx: ClassMethodDecoratorContext<Service, typeof method>,
681
- ) => void
678
+ ) => (this: Service, ...args: InferVariantTypes<InArgs>) => Promise<any>
682
679
 
683
680
  /**
684
681
  * Registers a method.
@@ -689,9 +686,9 @@ export function methodAsync<
689
686
  export function methodAsync<const InArgs extends Array<DBusType>>(
690
687
  ...inArgs: InArgs
691
688
  ): (
692
- method: (this: Service, ...args: InferVariantTypes<InArgs>) => Promise<void>,
689
+ method: (this: Service, ...args: any[]) => Promise<void>,
693
690
  ctx: ClassMethodDecoratorContext<Service, typeof method>,
694
- ) => void
691
+ ) => (this: Service, ...args: InferVariantTypes<InArgs>) => Promise<void>
695
692
 
696
693
  export function methodAsync<
697
694
  const InArgs extends Array<DBusType>,
@@ -703,10 +700,10 @@ export function methodAsync<
703
700
  ...args: InferVariantTypes<InArgs>
704
701
  ) => Promise<InferVariantTypes<OutArgs> | void>,
705
702
  ctx: ClassMethodDecoratorContext<Service, typeof method>,
706
- ): typeof method {
703
+ ): (this: Service, ...args: InferVariantTypes<InArgs>) => Promise<any> {
707
704
  const name = installMethod(args, method, ctx)
708
705
 
709
- return async function (...args: InferVariantTypes<InArgs>) {
706
+ return async function (...args) {
710
707
  if (this[internals].proxy) {
711
708
  const value = await this[remoteMethodAsync](name, args)
712
709
  return value.deepUnpack<InferVariantTypes<OutArgs>>()
@@ -729,7 +726,7 @@ export function property<T extends string>(type: T) {
729
726
  return function (
730
727
  _: void,
731
728
  ctx: ClassFieldDecoratorContext<Service, DeepInfer<T>>,
732
- ): (this: Service, init: DeepInfer<T>) => DeepInfer<T> {
729
+ ): (this: Service, init: DeepInfer<T>) => any {
733
730
  const name = installProperty(type, ctx)
734
731
 
735
732
  void gproperty({ $gtype: inferGTypeFromVariant(type) })(
@@ -768,8 +765,7 @@ export function property<T extends string>(type: T) {
768
765
  return function (init) {
769
766
  const priv = this[internals].priv
770
767
  priv[name] = init
771
- // we don't need to store the value on the object
772
- return void 0 as unknown as DeepInfer<T>
768
+ // we don't need to store the value on the object itself
773
769
  }
774
770
  }
775
771
  }
@@ -782,9 +778,9 @@ export function property<T extends string>(type: T) {
782
778
  */
783
779
  export function getter<T extends string>(type: T) {
784
780
  return function (
785
- getter: (this: Service) => DeepInfer<T>,
781
+ method: (this: Service) => DeepInfer<T>,
786
782
  ctx: ClassGetterDecoratorContext<Service, DeepInfer<T>>,
787
- ): (this: Service) => DeepInfer<T> {
783
+ ): (this: Service) => any {
788
784
  const name = installProperty(type, ctx)
789
785
 
790
786
  ctx.addInitializer(function () {
@@ -796,11 +792,11 @@ export function getter<T extends string>(type: T) {
796
792
  ctx as ClassGetterDecoratorContext<GObject.Object> & Ctx,
797
793
  )
798
794
 
799
- return function () {
795
+ return function get(): DeepInfer<T> {
800
796
  const { proxy } = this[internals]
801
797
  return proxy
802
798
  ? proxy.get_cached_property(name)!.deepUnpack<DeepInfer<T>>()
803
- : getter.call(this)
799
+ : method.call(this)
804
800
  }
805
801
  }
806
802
  }
@@ -813,7 +809,7 @@ export function getter<T extends string>(type: T) {
813
809
  */
814
810
  export function setter<T extends string>(type: T) {
815
811
  return function (
816
- setter: (this: Service, value: DeepInfer<T>) => void,
812
+ setter: (this: Service, value: any) => void,
817
813
  ctx: ClassSetterDecoratorContext<Service, DeepInfer<T>>,
818
814
  ): (this: Service, value: DeepInfer<T>) => void {
819
815
  const name = installProperty(type, ctx)
@@ -843,9 +839,9 @@ export function setter<T extends string>(type: T) {
843
839
  */
844
840
  export function signal<const Params extends Array<DBusType>>(...params: Params) {
845
841
  return function (
846
- method: (this: Service, ...params: InferVariantTypes<Params>) => void,
842
+ method: (this: Service, ...params: any) => void,
847
843
  ctx: ClassMethodDecoratorContext<Service, typeof method>,
848
- ): typeof method {
844
+ ): (this: Service, ...params: InferVariantTypes<Params>) => void {
849
845
  const name = installSignal(params, ctx)
850
846
 
851
847
  void gsignal(...params.map(inferGTypeFromVariant))(
@@ -853,7 +849,7 @@ export function signal<const Params extends Array<DBusType>>(...params: Params)
853
849
  ctx as ClassMethodDecoratorContext<GObject.Object> & Ctx,
854
850
  )
855
851
 
856
- return function (...params: InferVariantTypes<Params>) {
852
+ return function (...params) {
857
853
  if (this[internals].proxy) {
858
854
  console.warn(`cannot emit signal "${name}" on remote object`)
859
855
  }
Binary file
package/dist/gobject.ts CHANGED
@@ -104,7 +104,7 @@ export function property<T>(typeDeclaration: PropertyTypeDeclaration<T>) {
104
104
  _: void,
105
105
  ctx: PropertyContext<T>,
106
106
  options?: { metaOnly: true },
107
- ): (this: GObj, init: T) => T {
107
+ ): (this: GObj, init: T) => any {
108
108
  const fieldName = assertField(ctx)
109
109
  const key = kebabify(fieldName)
110
110
  const meta: Partial<Meta> = ctx.metadata!
@@ -160,7 +160,7 @@ export function property<T>(typeDeclaration: PropertyTypeDeclaration<T>) {
160
160
  * ```
161
161
  */
162
162
  export function getter<T>(typeDeclaration: PropertyTypeDeclaration<T>) {
163
- return function getter(getter: (this: GObj) => T, ctx: GetterContext<T>): (this: GObj) => T {
163
+ return function (get: (this: GObj) => any, ctx: GetterContext<T>) {
164
164
  const fieldName = assertField(ctx)
165
165
  const meta: Partial<Meta> = ctx.metadata!
166
166
  const props = (meta.properties ??= {})
@@ -170,7 +170,7 @@ export function getter<T>(typeDeclaration: PropertyTypeDeclaration<T>) {
170
170
  } else {
171
171
  props[fieldName] = { flags: ParamFlags.READABLE, type: typeDeclaration }
172
172
  }
173
- return getter
173
+ return get
174
174
  }
175
175
  }
176
176
 
@@ -194,10 +194,7 @@ export function getter<T>(typeDeclaration: PropertyTypeDeclaration<T>) {
194
194
  * ```
195
195
  */
196
196
  export function setter<T>(typeDeclaration: PropertyTypeDeclaration<T>) {
197
- return function setter(
198
- setter: (this: GObj, value: T) => void,
199
- ctx: SetterContext<T>,
200
- ): (this: GObj, value: T) => void {
197
+ return function (set: (this: GObj, value: any) => void, ctx: SetterContext<T>) {
201
198
  const fieldName = assertField(ctx)
202
199
  const meta: Partial<Meta> = ctx.metadata!
203
200
  const props = (meta.properties ??= {})
@@ -207,7 +204,7 @@ export function setter<T>(typeDeclaration: PropertyTypeDeclaration<T>) {
207
204
  } else {
208
205
  props[fieldName] = { flags: ParamFlags.WRITABLE, type: typeDeclaration }
209
206
  }
210
- return setter
207
+ return set
211
208
  }
212
209
  }
213
210
 
@@ -238,12 +235,12 @@ export function signal<
238
235
  Return extends { $gtype: GType } | GType,
239
236
  >(
240
237
  params: Params,
241
- returnType?: Return,
238
+ returnType: Return,
242
239
  options?: SignalOptions,
243
240
  ): (
244
- method: (this: GObj, ...args: ParamTypes<Params>) => ParamType<Return>,
241
+ method: (this: GObj, ...args: any) => ParamType<Return>,
245
242
  ctx: SignalContext<typeof method>,
246
- ) => typeof method
243
+ ) => (this: GObj, ...args: ParamTypes<Params>) => any
247
244
 
248
245
  /**
249
246
  * Defines a signal to be registered when using the {@link register} decorator.
@@ -261,9 +258,9 @@ export function signal<
261
258
  export function signal<Params extends Array<{ $gtype: GType } | GType>>(
262
259
  ...params: Params
263
260
  ): (
264
- method: (this: GObject.Object, ...args: ParamTypes<Params>) => void,
261
+ method: (this: GObject.Object, ...args: any) => void,
265
262
  ctx: SignalContext<typeof method>,
266
- ) => typeof method
263
+ ) => (this: GObject.Object, ...args: ParamTypes<Params>) => void
267
264
 
268
265
  export function signal<
269
266
  Params extends Array<{ $gtype: GType } | GType>,
package/dist/jsx/With.ts CHANGED
@@ -26,6 +26,7 @@ export function With<T, E extends JSX.Element>({
26
26
  const currentScope = getScope()
27
27
  const fragment = new Fragment<E>()
28
28
 
29
+ let currentValue: T
29
30
  let scope: Scope
30
31
 
31
32
  function remove(child: E) {
@@ -52,9 +53,14 @@ export function With<T, E extends JSX.Element>({
52
53
  }
53
54
 
54
55
  const dispose = value.subscribe(() => {
55
- callback(value.get())
56
+ const newValue = value.get()
57
+ if (currentValue === newValue) {
58
+ callback((currentValue = newValue))
59
+ }
56
60
  })
57
- callback(value.get())
61
+
62
+ currentValue = value.get()
63
+ callback(currentValue)
58
64
 
59
65
  onCleanup(() => {
60
66
  dispose()
package/dist/jsx/state.ts CHANGED
@@ -235,9 +235,9 @@ function createComputedArgs<
235
235
  if (subscribers.size === 0) {
236
236
  dispose = deps.map((dep, i) =>
237
237
  dep.subscribe(() => {
238
- const newValue = dep.get()
239
- if (cache[i] !== newValue) {
240
- cache[i] = dep.get()
238
+ const newDepValue = dep.get()
239
+ if (cache[i] !== newDepValue) {
240
+ cache[i] = newDepValue
241
241
 
242
242
  const newValue = compute()
243
243
  if (value !== newValue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gnim",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
4
4
  "type": "module",
5
5
  "author": "Aylur",
6
6
  "license": "MIT",