slint-ui 1.8.0-nightly.2024090417 → 1.8.0-nightly.2024091000

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/index.ts CHANGED
@@ -6,12 +6,10 @@ export {
6
6
  Diagnostic,
7
7
  DiagnosticLevel,
8
8
  RgbaColor,
9
- Brush
9
+ Brush,
10
10
  } from "./rust-module";
11
11
 
12
- import {
13
- Diagnostic
14
- } from "./rust-module.cjs";
12
+ import { Diagnostic } from "./rust-module.cjs";
15
13
 
16
14
  /**
17
15
  * Represents a two-dimensional point.
@@ -132,13 +130,13 @@ class ModelIterator<T> implements Iterator<T> {
132
130
  this.row++;
133
131
  return {
134
132
  done: false,
135
- value: this.model.rowData(row)
136
- }
133
+ value: this.model.rowData(row),
134
+ };
137
135
  }
138
136
  return {
139
137
  done: true,
140
- value: undefined
141
- }
138
+ value: undefined,
139
+ };
142
140
  }
143
141
  }
144
142
 
@@ -242,7 +240,7 @@ export abstract class Model<T> implements Iterable<T> {
242
240
  */
243
241
  setRowData(_row: number, _data: T): void {
244
242
  console.log(
245
- "setRowData called on a model which does not re-implement this method. This happens when trying to modify a read-only model"
243
+ "setRowData called on a model which does not re-implement this method. This happens when trying to modify a read-only model",
246
244
  );
247
245
  }
248
246
 
@@ -402,114 +400,114 @@ export namespace private_api {
402
400
  *
403
401
  * ```ts
404
402
  * import { Model, ArrayModel, MapModel } from "./index";
405
- *
406
- * interface Name {
407
- * first: string;
408
- * last: string;
409
- * }
410
- *
411
- * const model = new ArrayModel<Name>([
412
- * {
413
- * first: "Hans",
414
- * last: "Emil",
415
- * },
416
- * {
417
- * first: "Max",
418
- * last: "Mustermann",
419
- * },
420
- * {
421
- * first: "Roman",
422
- * last: "Tisch",
423
- * },
424
- * ]);
425
- *
426
- * const mappedModel = new MapModel(
427
- * model,
428
- * (data) => {
429
- * return data.last + ", " + data.first;
430
- * }
431
- * );
432
- *
433
- * // prints "Emil, Hans"
434
- * console.log(mappedModel.rowData(0));
435
- *
436
- * // prints "Mustermann, Max"
437
- * console.log(mappedModel.rowData(1));
438
- *
439
- * // prints "Tisch, Roman"
440
- * console.log(mappedModel.rowData(2));
441
- *
442
- * // Alternatively you can use the shortcut {@link MapModel.map}.
443
- *
444
- * const model = new ArrayModel<Name>([
445
- * {
446
- * first: "Hans",
447
- * last: "Emil",
448
- * },
449
- * {
450
- * first: "Max",
451
- * last: "Mustermann",
452
- * },
453
- * {
454
- * first: "Roman",
455
- * last: "Tisch",
456
- * },
457
- * ]);
458
- *
459
- * const mappedModel = model.map(
460
- * (data) => {
461
- * return data.last + ", " + data.first;
462
- * }
463
- * );
464
- *
465
- *
466
- * // prints "Emil, Hans"
467
- * console.log(mappedModel.rowData(0));
468
- *
469
- * // prints "Mustermann, Max"
470
- * console.log(mappedModel.rowData(1));
471
- *
472
- * // prints "Tisch, Roman"
473
- * console.log(mappedModel.rowData(2));
474
- *
475
- * // You can modifying the underlying {@link ArrayModel}:
476
- *
477
- * const model = new ArrayModel<Name>([
478
- * {
479
- * first: "Hans",
480
- * last: "Emil",
481
- * },
482
- * {
483
- * first: "Max",
484
- * last: "Mustermann",
485
- * },
486
- * {
487
- * first: "Roman",
488
- * last: "Tisch",
489
- * },
490
- * ]);
491
- *
492
- * const mappedModel = model.map(
493
- * (data) => {
494
- * return data.last + ", " + data.first;
495
- * }
496
- * );
497
- *
498
- * model.setRowData(1, { first: "Minnie", last: "Musterfrau" } );
499
- *
500
- * // prints "Emil, Hans"
501
- * console.log(mappedModel.rowData(0));
502
- *
503
- * // prints "Musterfrau, Minnie"
504
- * console.log(mappedModel.rowData(1));
505
- *
506
- * // prints "Tisch, Roman"
507
- * console.log(mappedModel.rowData(2));
508
- * ```
509
- */
403
+ *
404
+ * interface Name {
405
+ * first: string;
406
+ * last: string;
407
+ * }
408
+ *
409
+ * const model = new ArrayModel<Name>([
410
+ * {
411
+ * first: "Hans",
412
+ * last: "Emil",
413
+ * },
414
+ * {
415
+ * first: "Max",
416
+ * last: "Mustermann",
417
+ * },
418
+ * {
419
+ * first: "Roman",
420
+ * last: "Tisch",
421
+ * },
422
+ * ]);
423
+ *
424
+ * const mappedModel = new MapModel(
425
+ * model,
426
+ * (data) => {
427
+ * return data.last + ", " + data.first;
428
+ * }
429
+ * );
430
+ *
431
+ * // prints "Emil, Hans"
432
+ * console.log(mappedModel.rowData(0));
433
+ *
434
+ * // prints "Mustermann, Max"
435
+ * console.log(mappedModel.rowData(1));
436
+ *
437
+ * // prints "Tisch, Roman"
438
+ * console.log(mappedModel.rowData(2));
439
+ *
440
+ * // Alternatively you can use the shortcut {@link MapModel.map}.
441
+ *
442
+ * const model = new ArrayModel<Name>([
443
+ * {
444
+ * first: "Hans",
445
+ * last: "Emil",
446
+ * },
447
+ * {
448
+ * first: "Max",
449
+ * last: "Mustermann",
450
+ * },
451
+ * {
452
+ * first: "Roman",
453
+ * last: "Tisch",
454
+ * },
455
+ * ]);
456
+ *
457
+ * const mappedModel = model.map(
458
+ * (data) => {
459
+ * return data.last + ", " + data.first;
460
+ * }
461
+ * );
462
+ *
463
+ *
464
+ * // prints "Emil, Hans"
465
+ * console.log(mappedModel.rowData(0));
466
+ *
467
+ * // prints "Mustermann, Max"
468
+ * console.log(mappedModel.rowData(1));
469
+ *
470
+ * // prints "Tisch, Roman"
471
+ * console.log(mappedModel.rowData(2));
472
+ *
473
+ * // You can modifying the underlying {@link ArrayModel}:
474
+ *
475
+ * const model = new ArrayModel<Name>([
476
+ * {
477
+ * first: "Hans",
478
+ * last: "Emil",
479
+ * },
480
+ * {
481
+ * first: "Max",
482
+ * last: "Mustermann",
483
+ * },
484
+ * {
485
+ * first: "Roman",
486
+ * last: "Tisch",
487
+ * },
488
+ * ]);
489
+ *
490
+ * const mappedModel = model.map(
491
+ * (data) => {
492
+ * return data.last + ", " + data.first;
493
+ * }
494
+ * );
495
+ *
496
+ * model.setRowData(1, { first: "Minnie", last: "Musterfrau" } );
497
+ *
498
+ * // prints "Emil, Hans"
499
+ * console.log(mappedModel.rowData(0));
500
+ *
501
+ * // prints "Musterfrau, Minnie"
502
+ * console.log(mappedModel.rowData(1));
503
+ *
504
+ * // prints "Tisch, Roman"
505
+ * console.log(mappedModel.rowData(2));
506
+ * ```
507
+ */
510
508
  export class MapModel<T, U> extends Model<U> {
511
509
  readonly sourceModel: Model<T>;
512
- #mapFunction: (data: T) => U
510
+ #mapFunction: (data: T) => U;
513
511
 
514
512
  /**
515
513
  * Constructs the MapModel with a source model and map functions.
@@ -518,10 +516,7 @@ export namespace private_api {
518
516
  * @param sourceModel the wrapped model.
519
517
  * @param mapFunction maps the data from T to U.
520
518
  */
521
- constructor(
522
- sourceModel: Model<T>,
523
- mapFunction: (data: T) => U
524
- ) {
519
+ constructor(sourceModel: Model<T>, mapFunction: (data: T) => U) {
525
520
  super();
526
521
  this.sourceModel = sourceModel;
527
522
  this.#mapFunction = mapFunction;
@@ -598,8 +593,8 @@ class Component implements ComponentHandle {
598
593
  }
599
594
 
600
595
  /**
601
- * @hidden
602
- */
596
+ * @hidden
597
+ */
603
598
  get component_instance(): napi.ComponentInstance {
604
599
  return this.#instance;
605
600
  }
@@ -636,14 +631,15 @@ export class CompileError extends Error {
636
631
  */
637
632
  constructor(message: string, diagnostics: napi.Diagnostic[]) {
638
633
  const formattedDiagnostics = diagnostics
639
- .map((d) =>
640
- `[${d.fileName}:${d.lineNumber}:${d.columnNumber}] ${d.message}`
641
- )
642
- .join("\n");
643
-
634
+ .map(
635
+ (d) =>
636
+ `[${d.fileName}:${d.lineNumber}:${d.columnNumber}] ${d.message}`,
637
+ )
638
+ .join("\n");
639
+
644
640
  let formattedMessage = message;
645
641
  if (diagnostics.length > 0) {
646
- formattedMessage += `\nDiagnostics:\n${formattedDiagnostics}`;
642
+ formattedMessage += `\nDiagnostics:\n${formattedDiagnostics}`;
647
643
  }
648
644
 
649
645
  super(formattedMessage);
@@ -676,23 +672,25 @@ export interface LoadFileOptions {
676
672
  libraryPaths?: Record<string, string>;
677
673
  }
678
674
 
679
- type LoadData = {
680
- fileData: {
681
- filePath: string,
682
- options?: LoadFileOptions
683
- },
684
- from: 'file'
685
- } | {
686
- fileData: {
687
- source: string,
688
- filePath: string,
689
- options?: LoadFileOptions
690
- },
691
- from: 'source'
692
- }
675
+ type LoadData =
676
+ | {
677
+ fileData: {
678
+ filePath: string;
679
+ options?: LoadFileOptions;
680
+ };
681
+ from: "file";
682
+ }
683
+ | {
684
+ fileData: {
685
+ source: string;
686
+ filePath: string;
687
+ options?: LoadFileOptions;
688
+ };
689
+ from: "source";
690
+ };
693
691
 
694
692
  function loadSlint(loadData: LoadData): Object {
695
- const { filePath, options } = loadData.fileData
693
+ const { filePath, options } = loadData.fileData;
696
694
 
697
695
  let compiler = new napi.ComponentCompiler();
698
696
 
@@ -708,12 +706,15 @@ function loadSlint(loadData: LoadData): Object {
708
706
  }
709
707
  }
710
708
 
711
- let definitions = loadData.from === 'file' ? compiler.buildFromPath(filePath) : compiler.buildFromSource(loadData.fileData.source, filePath);
709
+ let definitions =
710
+ loadData.from === "file"
711
+ ? compiler.buildFromPath(filePath)
712
+ : compiler.buildFromSource(loadData.fileData.source, filePath);
712
713
  let diagnostics = compiler.diagnostics;
713
714
 
714
715
  if (diagnostics.length > 0) {
715
716
  let warnings = diagnostics.filter(
716
- (d) => d.level == napi.DiagnosticLevel.Warning
717
+ (d) => d.level === napi.DiagnosticLevel.Warning,
717
718
  );
718
719
 
719
720
  if (typeof options !== "undefined" && options.quiet !== true) {
@@ -721,7 +722,7 @@ function loadSlint(loadData: LoadData): Object {
721
722
  }
722
723
 
723
724
  let errors = diagnostics.filter(
724
- (d) => d.level == napi.DiagnosticLevel.Error
725
+ (d) => d.level === napi.DiagnosticLevel.Error,
725
726
  );
726
727
 
727
728
  if (errors.length > 0) {
@@ -734,156 +735,246 @@ function loadSlint(loadData: LoadData): Object {
734
735
  Object.keys(definitions).forEach((key) => {
735
736
  let definition = definitions[key];
736
737
 
737
- Object.defineProperty(slint_module, definition.name.replace(/-/g, "_"), {
738
- value: function (properties: any) {
739
- let instance = definition.create();
740
-
741
- if (instance == null) {
742
- throw Error(
743
- "Could not create a component handle for" + filePath
744
- );
745
- }
738
+ Object.defineProperty(
739
+ slint_module,
740
+ definition.name.replace(/-/g, "_"),
741
+ {
742
+ value: function (properties: any) {
743
+ let instance = definition.create();
744
+
745
+ if (instance == null) {
746
+ throw Error(
747
+ "Could not create a component handle for" +
748
+ filePath,
749
+ );
750
+ }
746
751
 
747
- for (var key in properties) {
748
- let value = properties[key];
752
+ for (var key in properties) {
753
+ let value = properties[key];
749
754
 
750
- if (value instanceof Function) {
751
- instance.setCallback(key, value);
752
- } else {
753
- instance.setProperty(key, properties[key]);
754
- }
755
- }
756
-
757
- let componentHandle = new Component(instance!);
758
- instance!.definition().properties.forEach((prop) => {
759
- let propName = prop.name.replace(/-/g, "_");
760
-
761
- if (componentHandle[propName] !== undefined) {
762
- console.warn("Duplicated property name " + propName);
763
- } else {
764
- Object.defineProperty(componentHandle, propName, {
765
- get() {
766
- return instance!.getProperty(prop.name);
767
- },
768
- set(value) {
769
- instance!.setProperty(prop.name, value);
770
- },
771
- enumerable: true,
772
- });
755
+ if (value instanceof Function) {
756
+ instance.setCallback(key, value);
757
+ } else {
758
+ instance.setProperty(key, properties[key]);
759
+ }
773
760
  }
774
- });
775
-
776
- instance!.definition().callbacks.forEach((cb) => {
777
- let callbackName = cb.replace(/-/g, "_");
778
-
779
- if (componentHandle[callbackName] !== undefined) {
780
- console.warn("Duplicated callback name " + callbackName);
781
- } else {
782
- Object.defineProperty(componentHandle, cb.replace(/-/g, "_"), {
783
- get() {
784
- return function () {
785
- return instance!.invoke(cb, Array.from(arguments));
786
- };
787
- },
788
- set(callback) {
789
- instance!.setCallback(cb, callback);
790
- },
791
- enumerable: true,
792
- });
793
- }
794
- });
795
-
796
- instance!.definition().functions.forEach((cb) => {
797
- let functionName = cb.replace(/-/g, "_");
798
-
799
- if (componentHandle[functionName] !== undefined) {
800
- console.warn("Duplicated function name " + functionName);
801
- } else {
802
- Object.defineProperty(componentHandle, cb.replace(/-/g, "_"), {
803
- get() {
804
- return function () {
805
- return instance!.invoke(cb, Array.from(arguments));
806
- };
807
- },
808
- enumerable: true,
809
- });
810
- }
811
- });
812
-
813
- // globals
814
- instance!.definition().globals.forEach((globalName) => {
815
- if (componentHandle[globalName] !== undefined) {
816
- console.warn("Duplicated property name " + globalName);
817
- } else {
818
- let globalObject = Object.create({});
819
-
820
- instance!.definition().globalProperties(globalName).forEach((prop) => {
821
- let propName = prop.name.replace(/-/g, "_");
822
-
823
- if (globalObject[propName] !== undefined) {
824
- console.warn("Duplicated property name " + propName + " on global " + global);
825
- } else {
826
- Object.defineProperty(globalObject, propName, {
827
- get() {
828
- return instance!.getGlobalProperty(globalName, prop.name);
829
- },
830
- set(value) {
831
- instance!.setGlobalProperty(globalName, prop.name, value);
832
- },
833
- enumerable: true,
834
- });
835
- }
836
- });
837
-
838
- instance!.definition().globalCallbacks(globalName).forEach((cb) => {
839
- let callbackName = cb.replace(/-/g, "_");
840
761
 
841
- if (globalObject[callbackName] !== undefined) {
842
- console.warn("Duplicated property name " + cb + " on global " + global);
843
- } else {
844
- Object.defineProperty(globalObject, cb.replace(/-/g, "_"), {
762
+ let componentHandle = new Component(instance!);
763
+ instance!.definition().properties.forEach((prop) => {
764
+ let propName = prop.name.replace(/-/g, "_");
765
+
766
+ if (componentHandle[propName] !== undefined) {
767
+ console.warn(
768
+ "Duplicated property name " + propName,
769
+ );
770
+ } else {
771
+ Object.defineProperty(componentHandle, propName, {
772
+ get() {
773
+ return instance!.getProperty(prop.name);
774
+ },
775
+ set(value) {
776
+ instance!.setProperty(prop.name, value);
777
+ },
778
+ enumerable: true,
779
+ });
780
+ }
781
+ });
782
+
783
+ instance!.definition().callbacks.forEach((cb) => {
784
+ let callbackName = cb.replace(/-/g, "_");
785
+
786
+ if (componentHandle[callbackName] !== undefined) {
787
+ console.warn(
788
+ "Duplicated callback name " + callbackName,
789
+ );
790
+ } else {
791
+ Object.defineProperty(
792
+ componentHandle,
793
+ cb.replace(/-/g, "_"),
794
+ {
845
795
  get() {
846
796
  return function () {
847
- return instance!.invokeGlobal(globalName, cb, Array.from(arguments));
797
+ return instance!.invoke(
798
+ cb,
799
+ Array.from(arguments),
800
+ );
848
801
  };
849
802
  },
850
803
  set(callback) {
851
- instance!.setGlobalCallback(globalName, cb, callback);
804
+ instance!.setCallback(cb, callback);
852
805
  },
853
806
  enumerable: true,
854
- });
855
- }
856
- });
857
-
858
- instance!.definition().globalFunctions(globalName).forEach((cb) => {
859
- let functionName = cb.replace(/-/g, "_");
860
-
861
- if (globalObject[functionName] !== undefined) {
862
- console.warn("Duplicated function name " + cb + " on global " + global);
863
- } else {
864
- Object.defineProperty(globalObject, cb.replace(/-/g, "_"), {
807
+ },
808
+ );
809
+ }
810
+ });
811
+
812
+ instance!.definition().functions.forEach((cb) => {
813
+ let functionName = cb.replace(/-/g, "_");
814
+
815
+ if (componentHandle[functionName] !== undefined) {
816
+ console.warn(
817
+ "Duplicated function name " + functionName,
818
+ );
819
+ } else {
820
+ Object.defineProperty(
821
+ componentHandle,
822
+ cb.replace(/-/g, "_"),
823
+ {
865
824
  get() {
866
825
  return function () {
867
- return instance!.invokeGlobal(globalName, cb, Array.from(arguments));
826
+ return instance!.invoke(
827
+ cb,
828
+ Array.from(arguments),
829
+ );
868
830
  };
869
831
  },
870
832
  enumerable: true,
833
+ },
834
+ );
835
+ }
836
+ });
837
+
838
+ // globals
839
+ instance!.definition().globals.forEach((globalName) => {
840
+ if (componentHandle[globalName] !== undefined) {
841
+ console.warn(
842
+ "Duplicated property name " + globalName,
843
+ );
844
+ } else {
845
+ let globalObject = Object.create({});
846
+
847
+ instance!
848
+ .definition()
849
+ .globalProperties(globalName)
850
+ .forEach((prop) => {
851
+ let propName = prop.name.replace(/-/g, "_");
852
+
853
+ if (globalObject[propName] !== undefined) {
854
+ console.warn(
855
+ "Duplicated property name " +
856
+ propName +
857
+ " on global " +
858
+ global,
859
+ );
860
+ } else {
861
+ Object.defineProperty(
862
+ globalObject,
863
+ propName,
864
+ {
865
+ get() {
866
+ return instance!.getGlobalProperty(
867
+ globalName,
868
+ prop.name,
869
+ );
870
+ },
871
+ set(value) {
872
+ instance!.setGlobalProperty(
873
+ globalName,
874
+ prop.name,
875
+ value,
876
+ );
877
+ },
878
+ enumerable: true,
879
+ },
880
+ );
881
+ }
882
+ });
883
+
884
+ instance!
885
+ .definition()
886
+ .globalCallbacks(globalName)
887
+ .forEach((cb) => {
888
+ let callbackName = cb.replace(/-/g, "_");
889
+
890
+ if (
891
+ globalObject[callbackName] !== undefined
892
+ ) {
893
+ console.warn(
894
+ "Duplicated property name " +
895
+ cb +
896
+ " on global " +
897
+ global,
898
+ );
899
+ } else {
900
+ Object.defineProperty(
901
+ globalObject,
902
+ cb.replace(/-/g, "_"),
903
+ {
904
+ get() {
905
+ return function () {
906
+ return instance!.invokeGlobal(
907
+ globalName,
908
+ cb,
909
+ Array.from(
910
+ arguments,
911
+ ),
912
+ );
913
+ };
914
+ },
915
+ set(callback) {
916
+ instance!.setGlobalCallback(
917
+ globalName,
918
+ cb,
919
+ callback,
920
+ );
921
+ },
922
+ enumerable: true,
923
+ },
924
+ );
925
+ }
926
+ });
927
+
928
+ instance!
929
+ .definition()
930
+ .globalFunctions(globalName)
931
+ .forEach((cb) => {
932
+ let functionName = cb.replace(/-/g, "_");
933
+
934
+ if (
935
+ globalObject[functionName] !== undefined
936
+ ) {
937
+ console.warn(
938
+ "Duplicated function name " +
939
+ cb +
940
+ " on global " +
941
+ global,
942
+ );
943
+ } else {
944
+ Object.defineProperty(
945
+ globalObject,
946
+ cb.replace(/-/g, "_"),
947
+ {
948
+ get() {
949
+ return function () {
950
+ return instance!.invokeGlobal(
951
+ globalName,
952
+ cb,
953
+ Array.from(
954
+ arguments,
955
+ ),
956
+ );
957
+ };
958
+ },
959
+ enumerable: true,
960
+ },
961
+ );
962
+ }
871
963
  });
872
- }
873
- });
874
-
875
- Object.defineProperty(componentHandle, globalName, {
876
- get() {
877
- return globalObject;
878
- },
879
- enumerable: true,
880
- });
881
- }
882
- });
883
964
 
884
- return Object.seal(componentHandle);
965
+ Object.defineProperty(componentHandle, globalName, {
966
+ get() {
967
+ return globalObject;
968
+ },
969
+ enumerable: true,
970
+ });
971
+ }
972
+ });
973
+
974
+ return Object.seal(componentHandle);
975
+ },
885
976
  },
886
- });
977
+ );
887
978
  });
888
979
  return Object.seal(slint_module);
889
980
  }
@@ -923,8 +1014,8 @@ function loadSlint(loadData: LoadData): Object {
923
1014
  export function loadFile(filePath: string, options?: LoadFileOptions): Object {
924
1015
  return loadSlint({
925
1016
  fileData: { filePath, options },
926
- from: 'file',
927
- })
1017
+ from: "file",
1018
+ });
928
1019
  }
929
1020
 
930
1021
  /**
@@ -955,11 +1046,15 @@ export function loadFile(filePath: string, options?: LoadFileOptions): Object {
955
1046
  * For further information on the available properties, refer to [Instantiating A Component](../index.html#md:instantiating-a-component).
956
1047
  * @throws {@link CompileError} if errors occur during compilation.
957
1048
  */
958
- export function loadSource(source: string, filePath: string, options?: LoadFileOptions): Object {
1049
+ export function loadSource(
1050
+ source: string,
1051
+ filePath: string,
1052
+ options?: LoadFileOptions,
1053
+ ): Object {
959
1054
  return loadSlint({
960
1055
  fileData: { filePath, options, source },
961
- from: 'source',
962
- })
1056
+ from: "source",
1057
+ });
963
1058
  }
964
1059
 
965
1060
  class EventLoop {
@@ -967,10 +1062,12 @@ class EventLoop {
967
1062
  #terminationPromise: Promise<unknown> | null = null;
968
1063
  #terminateResolveFn: ((_value: unknown) => void) | null;
969
1064
 
970
- constructor() {
971
- }
1065
+ constructor() {}
972
1066
 
973
- start(running_callback?: Function, quitOnLastWindowClosed: boolean = true): Promise<unknown> {
1067
+ start(
1068
+ running_callback?: Function,
1069
+ quitOnLastWindowClosed: boolean = true,
1070
+ ): Promise<unknown> {
974
1071
  if (this.#terminationPromise != null) {
975
1072
  return this.#terminationPromise;
976
1073
  }
@@ -982,7 +1079,7 @@ class EventLoop {
982
1079
 
983
1080
  napi.setQuitOnLastWindowClosed(quitOnLastWindowClosed);
984
1081
 
985
- if (running_callback != undefined) {
1082
+ if (running_callback !== undefined) {
986
1083
  napi.invokeFromEventLoop(() => {
987
1084
  running_callback();
988
1085
  running_callback = undefined;
@@ -993,7 +1090,10 @@ class EventLoop {
993
1090
  // can do right now.
994
1091
  const nodejsPollInterval = 16;
995
1092
  let id = setInterval(() => {
996
- if (napi.processEvents() == napi.ProcessEventsResult.Exited || this.#quit_loop) {
1093
+ if (
1094
+ napi.processEvents() === napi.ProcessEventsResult.Exited ||
1095
+ this.#quit_loop
1096
+ ) {
997
1097
  clearInterval(id);
998
1098
  this.#terminateResolveFn!(undefined);
999
1099
  this.#terminateResolveFn = null;
@@ -1010,7 +1110,7 @@ class EventLoop {
1010
1110
  }
1011
1111
  }
1012
1112
 
1013
- var globalEventLoop: EventLoop = new EventLoop;
1113
+ var globalEventLoop: EventLoop = new EventLoop();
1014
1114
 
1015
1115
  /**
1016
1116
  * Spins the Slint event loop and returns a promise that resolves when the loop terminates.
@@ -1032,7 +1132,11 @@ var globalEventLoop: EventLoop = new EventLoop;
1032
1132
  * application is idle, it continues to consume a low amount of CPU cycles, checking if either
1033
1133
  * event loop has any pending events.
1034
1134
  */
1035
- export function runEventLoop(args?: Function | { runningCallback?: Function; quitOnLastWindowClosed?: boolean }): Promise<unknown> {
1135
+ export function runEventLoop(
1136
+ args?:
1137
+ | Function
1138
+ | { runningCallback?: Function; quitOnLastWindowClosed?: boolean },
1139
+ ): Promise<unknown> {
1036
1140
  if (args === undefined) {
1037
1141
  return globalEventLoop.start(undefined);
1038
1142
  }
@@ -1041,7 +1145,10 @@ export function runEventLoop(args?: Function | { runningCallback?: Function; qui
1041
1145
  return globalEventLoop.start(args);
1042
1146
  }
1043
1147
 
1044
- return globalEventLoop.start(args.runningCallback, args.quitOnLastWindowClosed);
1148
+ return globalEventLoop.start(
1149
+ args.runningCallback,
1150
+ args.quitOnLastWindowClosed,
1151
+ );
1045
1152
  }
1046
1153
 
1047
1154
  /**
@@ -1049,7 +1156,7 @@ export function runEventLoop(args?: Function | { runningCallback?: Function; qui
1049
1156
  from run_event_loop() will resolve in a later tick of the nodejs event loop.
1050
1157
  */
1051
1158
  export function quitEventLoop() {
1052
- globalEventLoop.quit()
1159
+ globalEventLoop.quit();
1053
1160
  }
1054
1161
 
1055
1162
  /**
@@ -1073,14 +1180,14 @@ export namespace private_api {
1073
1180
  export function send_mouse_click(
1074
1181
  component: Component,
1075
1182
  x: number,
1076
- y: number
1183
+ y: number,
1077
1184
  ) {
1078
1185
  component.component_instance.sendMouseClick(x, y);
1079
1186
  }
1080
1187
 
1081
1188
  export function send_keyboard_string_sequence(
1082
1189
  component: Component,
1083
- s: string
1190
+ s: string,
1084
1191
  ) {
1085
1192
  component.component_instance.sendKeyboardStringSequence(s);
1086
1193
  }