slint-ui 1.8.0-nightly.2024090616 → 1.8.0-nightly.2024091017

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.js CHANGED
@@ -17,12 +17,12 @@ class ModelIterator {
17
17
  this.row++;
18
18
  return {
19
19
  done: false,
20
- value: this.model.rowData(row)
20
+ value: this.model.rowData(row),
21
21
  };
22
22
  }
23
23
  return {
24
24
  done: true,
25
- value: undefined
25
+ value: undefined,
26
26
  };
27
27
  }
28
28
  }
@@ -245,111 +245,111 @@ var private_api;
245
245
  *
246
246
  * ```ts
247
247
  * import { Model, ArrayModel, MapModel } from "./index";
248
- *
249
- * interface Name {
250
- * first: string;
251
- * last: string;
252
- * }
253
- *
254
- * const model = new ArrayModel<Name>([
255
- * {
256
- * first: "Hans",
257
- * last: "Emil",
258
- * },
259
- * {
260
- * first: "Max",
261
- * last: "Mustermann",
262
- * },
263
- * {
264
- * first: "Roman",
265
- * last: "Tisch",
266
- * },
267
- * ]);
268
- *
269
- * const mappedModel = new MapModel(
270
- * model,
271
- * (data) => {
272
- * return data.last + ", " + data.first;
273
- * }
274
- * );
275
- *
276
- * // prints "Emil, Hans"
277
- * console.log(mappedModel.rowData(0));
278
- *
279
- * // prints "Mustermann, Max"
280
- * console.log(mappedModel.rowData(1));
281
- *
282
- * // prints "Tisch, Roman"
283
- * console.log(mappedModel.rowData(2));
284
- *
285
- * // Alternatively you can use the shortcut {@link MapModel.map}.
286
- *
287
- * const model = new ArrayModel<Name>([
288
- * {
289
- * first: "Hans",
290
- * last: "Emil",
291
- * },
292
- * {
293
- * first: "Max",
294
- * last: "Mustermann",
295
- * },
296
- * {
297
- * first: "Roman",
298
- * last: "Tisch",
299
- * },
300
- * ]);
301
- *
302
- * const mappedModel = model.map(
303
- * (data) => {
304
- * return data.last + ", " + data.first;
305
- * }
306
- * );
307
- *
308
- *
309
- * // prints "Emil, Hans"
310
- * console.log(mappedModel.rowData(0));
311
- *
312
- * // prints "Mustermann, Max"
313
- * console.log(mappedModel.rowData(1));
314
- *
315
- * // prints "Tisch, Roman"
316
- * console.log(mappedModel.rowData(2));
317
- *
318
- * // You can modifying the underlying {@link ArrayModel}:
319
- *
320
- * const model = new ArrayModel<Name>([
321
- * {
322
- * first: "Hans",
323
- * last: "Emil",
324
- * },
325
- * {
326
- * first: "Max",
327
- * last: "Mustermann",
328
- * },
329
- * {
330
- * first: "Roman",
331
- * last: "Tisch",
332
- * },
333
- * ]);
334
- *
335
- * const mappedModel = model.map(
336
- * (data) => {
337
- * return data.last + ", " + data.first;
338
- * }
339
- * );
340
- *
341
- * model.setRowData(1, { first: "Minnie", last: "Musterfrau" } );
342
- *
343
- * // prints "Emil, Hans"
344
- * console.log(mappedModel.rowData(0));
345
- *
346
- * // prints "Musterfrau, Minnie"
347
- * console.log(mappedModel.rowData(1));
348
- *
349
- * // prints "Tisch, Roman"
350
- * console.log(mappedModel.rowData(2));
351
- * ```
352
- */
248
+ *
249
+ * interface Name {
250
+ * first: string;
251
+ * last: string;
252
+ * }
253
+ *
254
+ * const model = new ArrayModel<Name>([
255
+ * {
256
+ * first: "Hans",
257
+ * last: "Emil",
258
+ * },
259
+ * {
260
+ * first: "Max",
261
+ * last: "Mustermann",
262
+ * },
263
+ * {
264
+ * first: "Roman",
265
+ * last: "Tisch",
266
+ * },
267
+ * ]);
268
+ *
269
+ * const mappedModel = new MapModel(
270
+ * model,
271
+ * (data) => {
272
+ * return data.last + ", " + data.first;
273
+ * }
274
+ * );
275
+ *
276
+ * // prints "Emil, Hans"
277
+ * console.log(mappedModel.rowData(0));
278
+ *
279
+ * // prints "Mustermann, Max"
280
+ * console.log(mappedModel.rowData(1));
281
+ *
282
+ * // prints "Tisch, Roman"
283
+ * console.log(mappedModel.rowData(2));
284
+ *
285
+ * // Alternatively you can use the shortcut {@link MapModel.map}.
286
+ *
287
+ * const model = new ArrayModel<Name>([
288
+ * {
289
+ * first: "Hans",
290
+ * last: "Emil",
291
+ * },
292
+ * {
293
+ * first: "Max",
294
+ * last: "Mustermann",
295
+ * },
296
+ * {
297
+ * first: "Roman",
298
+ * last: "Tisch",
299
+ * },
300
+ * ]);
301
+ *
302
+ * const mappedModel = model.map(
303
+ * (data) => {
304
+ * return data.last + ", " + data.first;
305
+ * }
306
+ * );
307
+ *
308
+ *
309
+ * // prints "Emil, Hans"
310
+ * console.log(mappedModel.rowData(0));
311
+ *
312
+ * // prints "Mustermann, Max"
313
+ * console.log(mappedModel.rowData(1));
314
+ *
315
+ * // prints "Tisch, Roman"
316
+ * console.log(mappedModel.rowData(2));
317
+ *
318
+ * // You can modifying the underlying {@link ArrayModel}:
319
+ *
320
+ * const model = new ArrayModel<Name>([
321
+ * {
322
+ * first: "Hans",
323
+ * last: "Emil",
324
+ * },
325
+ * {
326
+ * first: "Max",
327
+ * last: "Mustermann",
328
+ * },
329
+ * {
330
+ * first: "Roman",
331
+ * last: "Tisch",
332
+ * },
333
+ * ]);
334
+ *
335
+ * const mappedModel = model.map(
336
+ * (data) => {
337
+ * return data.last + ", " + data.first;
338
+ * }
339
+ * );
340
+ *
341
+ * model.setRowData(1, { first: "Minnie", last: "Musterfrau" } );
342
+ *
343
+ * // prints "Emil, Hans"
344
+ * console.log(mappedModel.rowData(0));
345
+ *
346
+ * // prints "Musterfrau, Minnie"
347
+ * console.log(mappedModel.rowData(1));
348
+ *
349
+ * // prints "Tisch, Roman"
350
+ * console.log(mappedModel.rowData(2));
351
+ * ```
352
+ */
353
353
  class MapModel extends Model {
354
354
  sourceModel;
355
355
  #mapFunction;
@@ -401,8 +401,8 @@ class Component {
401
401
  return this.#instance.window();
402
402
  }
403
403
  /**
404
- * @hidden
405
- */
404
+ * @hidden
405
+ */
406
406
  get component_instance() {
407
407
  return this.#instance;
408
408
  }
@@ -459,14 +459,16 @@ function loadSlint(loadData) {
459
459
  compiler.libraryPaths = options.libraryPaths;
460
460
  }
461
461
  }
462
- let definitions = loadData.from === 'file' ? compiler.buildFromPath(filePath) : compiler.buildFromSource(loadData.fileData.source, filePath);
462
+ let definitions = loadData.from === "file"
463
+ ? compiler.buildFromPath(filePath)
464
+ : compiler.buildFromSource(loadData.fileData.source, filePath);
463
465
  let diagnostics = compiler.diagnostics;
464
466
  if (diagnostics.length > 0) {
465
- let warnings = diagnostics.filter((d) => d.level == napi.DiagnosticLevel.Warning);
467
+ let warnings = diagnostics.filter((d) => d.level === napi.DiagnosticLevel.Warning);
466
468
  if (typeof options !== "undefined" && options.quiet !== true) {
467
469
  warnings.forEach((w) => console.warn("Warning: " + w));
468
470
  }
469
- let errors = diagnostics.filter((d) => d.level == napi.DiagnosticLevel.Error);
471
+ let errors = diagnostics.filter((d) => d.level === napi.DiagnosticLevel.Error);
470
472
  if (errors.length > 0) {
471
473
  throw new CompileError("Could not compile " + filePath, errors);
472
474
  }
@@ -478,7 +480,8 @@ function loadSlint(loadData) {
478
480
  value: function (properties) {
479
481
  let instance = definition.create();
480
482
  if (instance == null) {
481
- throw Error("Could not create a component handle for" + filePath);
483
+ throw Error("Could not create a component handle for" +
484
+ filePath);
482
485
  }
483
486
  for (var key in properties) {
484
487
  let value = properties[key];
@@ -549,10 +552,16 @@ function loadSlint(loadData) {
549
552
  }
550
553
  else {
551
554
  let globalObject = Object.create({});
552
- instance.definition().globalProperties(globalName).forEach((prop) => {
555
+ instance
556
+ .definition()
557
+ .globalProperties(globalName)
558
+ .forEach((prop) => {
553
559
  let propName = prop.name.replace(/-/g, "_");
554
560
  if (globalObject[propName] !== undefined) {
555
- console.warn("Duplicated property name " + propName + " on global " + global);
561
+ console.warn("Duplicated property name " +
562
+ propName +
563
+ " on global " +
564
+ global);
556
565
  }
557
566
  else {
558
567
  Object.defineProperty(globalObject, propName, {
@@ -566,10 +575,16 @@ function loadSlint(loadData) {
566
575
  });
567
576
  }
568
577
  });
569
- instance.definition().globalCallbacks(globalName).forEach((cb) => {
578
+ instance
579
+ .definition()
580
+ .globalCallbacks(globalName)
581
+ .forEach((cb) => {
570
582
  let callbackName = cb.replace(/-/g, "_");
571
583
  if (globalObject[callbackName] !== undefined) {
572
- console.warn("Duplicated property name " + cb + " on global " + global);
584
+ console.warn("Duplicated property name " +
585
+ cb +
586
+ " on global " +
587
+ global);
573
588
  }
574
589
  else {
575
590
  Object.defineProperty(globalObject, cb.replace(/-/g, "_"), {
@@ -585,10 +600,16 @@ function loadSlint(loadData) {
585
600
  });
586
601
  }
587
602
  });
588
- instance.definition().globalFunctions(globalName).forEach((cb) => {
603
+ instance
604
+ .definition()
605
+ .globalFunctions(globalName)
606
+ .forEach((cb) => {
589
607
  let functionName = cb.replace(/-/g, "_");
590
608
  if (globalObject[functionName] !== undefined) {
591
- console.warn("Duplicated function name " + cb + " on global " + global);
609
+ console.warn("Duplicated function name " +
610
+ cb +
611
+ " on global " +
612
+ global);
592
613
  }
593
614
  else {
594
615
  Object.defineProperty(globalObject, cb.replace(/-/g, "_"), {
@@ -650,7 +671,7 @@ function loadSlint(loadData) {
650
671
  function loadFile(filePath, options) {
651
672
  return loadSlint({
652
673
  fileData: { filePath, options },
653
- from: 'file',
674
+ from: "file",
654
675
  });
655
676
  }
656
677
  exports.loadFile = loadFile;
@@ -685,7 +706,7 @@ exports.loadFile = loadFile;
685
706
  function loadSource(source, filePath, options) {
686
707
  return loadSlint({
687
708
  fileData: { filePath, options, source },
688
- from: 'source',
709
+ from: "source",
689
710
  });
690
711
  }
691
712
  exports.loadSource = loadSource;
@@ -693,8 +714,7 @@ class EventLoop {
693
714
  #quit_loop = false;
694
715
  #terminationPromise = null;
695
716
  #terminateResolveFn;
696
- constructor() {
697
- }
717
+ constructor() { }
698
718
  start(running_callback, quitOnLastWindowClosed = true) {
699
719
  if (this.#terminationPromise != null) {
700
720
  return this.#terminationPromise;
@@ -704,7 +724,7 @@ class EventLoop {
704
724
  });
705
725
  this.#quit_loop = false;
706
726
  napi.setQuitOnLastWindowClosed(quitOnLastWindowClosed);
707
- if (running_callback != undefined) {
727
+ if (running_callback !== undefined) {
708
728
  napi.invokeFromEventLoop(() => {
709
729
  running_callback();
710
730
  running_callback = undefined;
@@ -714,7 +734,8 @@ class EventLoop {
714
734
  // can do right now.
715
735
  const nodejsPollInterval = 16;
716
736
  let id = setInterval(() => {
717
- if (napi.processEvents() == napi.ProcessEventsResult.Exited || this.#quit_loop) {
737
+ if (napi.processEvents() === napi.ProcessEventsResult.Exited ||
738
+ this.#quit_loop) {
718
739
  clearInterval(id);
719
740
  this.#terminateResolveFn(undefined);
720
741
  this.#terminateResolveFn = null;
@@ -728,7 +749,7 @@ class EventLoop {
728
749
  this.#quit_loop = true;
729
750
  }
730
751
  }
731
- var globalEventLoop = new EventLoop;
752
+ var globalEventLoop = new EventLoop();
732
753
  /**
733
754
  * Spins the Slint event loop and returns a promise that resolves when the loop terminates.
734
755
  *