lido-player 0.0.2-alpha-92 → 0.0.2-alpha-93

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-rb5JkNCU.js');
3
+ var index = require('./index-DA8gicLI.js');
4
4
 
5
5
  function _mergeNamespaces(n, m) {
6
6
  m.forEach(function (e) {
@@ -1064,9 +1064,12 @@ async function onClickDropOrDragElement(element, type) {
1064
1064
  const selectedDropElement = type === 'drop' ? element : document.querySelector("[type='drop'].highlight-element");
1065
1065
  const selectedDragElement = type === 'drag' ? element : document.querySelector("[type='drag'].highlight-element");
1066
1066
  if (!selectedDropElement || element.classList.contains("dropped")) {
1067
+ console.log("hello");
1067
1068
  onClickDragElement(element);
1068
1069
  return;
1069
1070
  }
1071
+ if (element.classList.contains("drop-element"))
1072
+ return;
1070
1073
  if (selectedDropElement && selectedDragElement) {
1071
1074
  if (selectedDragElement.getAttribute('drop-to'))
1072
1075
  return;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-rb5JkNCU.js');
3
+ var index = require('./index-DA8gicLI.js');
4
4
  require('./index-Dl8SlqP-.js');
5
5
 
6
6
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-Dl8SlqP-.js');
4
- var index$1 = require('./index-rb5JkNCU.js');
4
+ var index$1 = require('./index-DA8gicLI.js');
5
5
 
6
6
  var rive$1 = {exports: {}};
7
7
 
@@ -12709,6 +12709,15 @@ const LidoHome = class {
12709
12709
  }
12710
12710
  }, 100);
12711
12711
  };
12712
+ this.btnpopupRunId = 0;
12713
+ this.handleWindowTouch = () => {
12714
+ void this.cancelBtnpopupRun();
12715
+ };
12716
+ this.handleWindowPointer = (event) => {
12717
+ if (event.pointerType !== 'touch')
12718
+ return;
12719
+ void this.cancelBtnpopupRun();
12720
+ };
12712
12721
  this.popUpClick = (comment) => {
12713
12722
  const alertElement = this.el.querySelector('.lido-alert-popup');
12714
12723
  this.exitFlag = false;
@@ -12843,7 +12852,7 @@ const LidoHome = class {
12843
12852
  }
12844
12853
  // Pure-JS fallback (no wasm asset required)
12845
12854
  try {
12846
- const brotliDecodeModule = await Promise.resolve().then(function () { return require('./decode-C3sBXlW1.js'); }).then(function (n) { return n.decode; });
12855
+ const brotliDecodeModule = await Promise.resolve().then(function () { return require('./decode-BaNHxjfg.js'); }).then(function (n) { return n.decode; });
12847
12856
  const brotliDecompressBuffer = brotliDecodeModule.BrotliDecompressBuffer || ((_a = brotliDecodeModule.default) === null || _a === void 0 ? void 0 : _a.BrotliDecompressBuffer);
12848
12857
  if (typeof brotliDecompressBuffer !== 'function') {
12849
12858
  throw new Error('BrotliDecompressBuffer function not found in brotli/dec/decode');
@@ -12872,6 +12881,8 @@ const LidoHome = class {
12872
12881
  window.addEventListener('resize', () => {
12873
12882
  this.scaleNavbarContainer(); // re-scale navbar on resize
12874
12883
  });
12884
+ window.addEventListener('touchstart', this.handleWindowTouch, { passive: true });
12885
+ window.addEventListener('pointerdown', this.handleWindowPointer, { passive: true });
12875
12886
  }
12876
12887
  publishCommonAudioPath(path) {
12877
12888
  if (!path)
@@ -12944,6 +12955,8 @@ const LidoHome = class {
12944
12955
  window.removeEventListener('resize', () => {
12945
12956
  this.scaleNavbarContainer(); // clean up
12946
12957
  });
12958
+ window.removeEventListener('touchstart', this.handleWindowTouch);
12959
+ window.removeEventListener('pointerdown', this.handleWindowPointer);
12947
12960
  }
12948
12961
  /**
12949
12962
  * Parses the provided XML string into an XML DOM object and extracts the containers from it.
@@ -13087,24 +13100,31 @@ const LidoHome = class {
13087
13100
  return drags.some(drag => drag.getAttribute('drop-to') === dropId);
13088
13101
  });
13089
13102
  }
13090
- async btnpopup() {
13103
+ async btnpopup(runId) {
13091
13104
  var _a, _b;
13105
+ const isStale = () => runId !== this.btnpopupRunId;
13092
13106
  const container = document.getElementById(index$1.LidoContainer);
13093
13107
  console.log('game completed !');
13108
+ if (isStale())
13109
+ return;
13094
13110
  if (!container || container.getAttribute('game-completed') === 'true')
13095
13111
  return;
13096
13112
  index$1.setCancelBtnPopup(false);
13097
13113
  await index$1.AudioPlayer.getI().stop();
13114
+ if (isStale())
13115
+ return;
13098
13116
  const allele = container.querySelectorAll('*');
13099
13117
  const templateId = container.getAttribute(index$1.TemplateID);
13100
13118
  if (templateId) {
13101
13119
  const instructEl = this.el.querySelector(`#${templateId}`);
13102
13120
  if (instructEl) {
13103
13121
  await index$1.executeActions("this.speak='true';", instructEl);
13122
+ if (isStale())
13123
+ return;
13104
13124
  }
13105
13125
  }
13106
13126
  for (const el of Array.from(allele)) {
13107
- if (index$1.getCancelBtnPopup())
13127
+ if (index$1.getCancelBtnPopup() || isStale())
13108
13128
  break;
13109
13129
  const tabIndex = el.getAttribute('tab-index');
13110
13130
  const htmlel = el;
@@ -13122,13 +13142,17 @@ const LidoHome = class {
13122
13142
  !type || !type.trim())) {
13123
13143
  await index$1.AudioPlayer.getI().play(htmlel);
13124
13144
  }
13125
- if (index$1.getCancelBtnPopup()) {
13145
+ if (index$1.getCancelBtnPopup() || isStale()) {
13126
13146
  await index$1.AudioPlayer.getI().stop();
13127
13147
  break;
13128
13148
  }
13129
13149
  await new Promise(resolve => setTimeout(resolve, 300));
13150
+ if (isStale())
13151
+ break;
13130
13152
  }
13131
13153
  }
13154
+ if (isStale())
13155
+ return;
13132
13156
  if (this.areAllDropsFilled()) {
13133
13157
  const objectiveString = container['objective'];
13134
13158
  const objectiveArray = (_b = JSON.parse((_a = container.getAttribute(index$1.SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]')) !== null && _b !== void 0 ? _b : [];
@@ -13145,6 +13169,19 @@ const LidoHome = class {
13145
13169
  console.log('Not yet filled ');
13146
13170
  }
13147
13171
  }
13172
+ async cancelBtnpopupRun() {
13173
+ this.btnpopupRunId++;
13174
+ index$1.setCancelBtnPopup(true);
13175
+ await index$1.AudioPlayer.getI().stop();
13176
+ }
13177
+ async handleBtnpopupClick() {
13178
+ // Invalidate any in-flight run and stop audio immediately.
13179
+ await this.cancelBtnpopupRun();
13180
+ // Start fresh run.
13181
+ const nextRunId = this.btnpopupRunId;
13182
+ index$1.setCancelBtnPopup(false);
13183
+ await this.btnpopup(nextRunId);
13184
+ }
13148
13185
  scaleNavbarContainer() {
13149
13186
  setTimeout(() => {
13150
13187
  const navBar = document.querySelector('.lido-dot-container');
@@ -13189,7 +13226,7 @@ const LidoHome = class {
13189
13226
  console.log('Current Target:', event.currentTarget); // Where the onClick is bound
13190
13227
  console.log('✅ Button clicked - nextBtn action triggered');
13191
13228
  index$1.executeActions("this.nextBtn='true'", event.currentTarget);
13192
- } }, index.h("lido-image", { src: this.navBarIcons.next }))), index.h("div", { id: "main-audio", class: "popup-button", onClick: () => this.btnpopup() }, index.h("lido-image", { visible: "true", src: this.navBarIcons.speak }))));
13229
+ } }, index.h("lido-image", { src: this.navBarIcons.next }))), index.h("div", { id: "main-audio", class: "popup-button", onClick: () => this.handleBtnpopupClick() }, index.h("lido-image", { visible: "true", src: this.navBarIcons.speak }))));
13193
13230
  }
13194
13231
  /**
13195
13232
  * Jumps to a specific container based on the index of the dot clicked.
@@ -144,6 +144,15 @@ export class LidoHome {
144
144
  }
145
145
  }, 100);
146
146
  };
147
+ this.btnpopupRunId = 0;
148
+ this.handleWindowTouch = () => {
149
+ void this.cancelBtnpopupRun();
150
+ };
151
+ this.handleWindowPointer = (event) => {
152
+ if (event.pointerType !== 'touch')
153
+ return;
154
+ void this.cancelBtnpopupRun();
155
+ };
147
156
  this.popUpClick = (comment) => {
148
157
  const alertElement = this.el.querySelector('.lido-alert-popup');
149
158
  this.exitFlag = false;
@@ -307,6 +316,8 @@ export class LidoHome {
307
316
  window.addEventListener('resize', () => {
308
317
  this.scaleNavbarContainer(); // re-scale navbar on resize
309
318
  });
319
+ window.addEventListener('touchstart', this.handleWindowTouch, { passive: true });
320
+ window.addEventListener('pointerdown', this.handleWindowPointer, { passive: true });
310
321
  }
311
322
  publishCommonAudioPath(path) {
312
323
  if (!path)
@@ -379,6 +390,8 @@ export class LidoHome {
379
390
  window.removeEventListener('resize', () => {
380
391
  this.scaleNavbarContainer(); // clean up
381
392
  });
393
+ window.removeEventListener('touchstart', this.handleWindowTouch);
394
+ window.removeEventListener('pointerdown', this.handleWindowPointer);
382
395
  }
383
396
  /**
384
397
  * Parses the provided XML string into an XML DOM object and extracts the containers from it.
@@ -522,24 +535,31 @@ export class LidoHome {
522
535
  return drags.some(drag => drag.getAttribute('drop-to') === dropId);
523
536
  });
524
537
  }
525
- async btnpopup() {
538
+ async btnpopup(runId) {
526
539
  var _a, _b;
540
+ const isStale = () => runId !== this.btnpopupRunId;
527
541
  const container = document.getElementById(LidoContainer);
528
542
  console.log('game completed !');
543
+ if (isStale())
544
+ return;
529
545
  if (!container || container.getAttribute('game-completed') === 'true')
530
546
  return;
531
547
  setCancelBtnPopup(false);
532
548
  await AudioPlayer.getI().stop();
549
+ if (isStale())
550
+ return;
533
551
  const allele = container.querySelectorAll('*');
534
552
  const templateId = container.getAttribute(TemplateID);
535
553
  if (templateId) {
536
554
  const instructEl = this.el.querySelector(`#${templateId}`);
537
555
  if (instructEl) {
538
556
  await executeActions("this.speak='true';", instructEl);
557
+ if (isStale())
558
+ return;
539
559
  }
540
560
  }
541
561
  for (const el of Array.from(allele)) {
542
- if (getCancelBtnPopup())
562
+ if (getCancelBtnPopup() || isStale())
543
563
  break;
544
564
  const tabIndex = el.getAttribute('tab-index');
545
565
  const htmlel = el;
@@ -557,13 +577,17 @@ export class LidoHome {
557
577
  !type || !type.trim())) {
558
578
  await AudioPlayer.getI().play(htmlel);
559
579
  }
560
- if (getCancelBtnPopup()) {
580
+ if (getCancelBtnPopup() || isStale()) {
561
581
  await AudioPlayer.getI().stop();
562
582
  break;
563
583
  }
564
584
  await new Promise(resolve => setTimeout(resolve, 300));
585
+ if (isStale())
586
+ break;
565
587
  }
566
588
  }
589
+ if (isStale())
590
+ return;
567
591
  if (this.areAllDropsFilled()) {
568
592
  const objectiveString = container['objective'];
569
593
  const objectiveArray = (_b = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]')) !== null && _b !== void 0 ? _b : [];
@@ -580,6 +604,19 @@ export class LidoHome {
580
604
  console.log('Not yet filled ');
581
605
  }
582
606
  }
607
+ async cancelBtnpopupRun() {
608
+ this.btnpopupRunId++;
609
+ setCancelBtnPopup(true);
610
+ await AudioPlayer.getI().stop();
611
+ }
612
+ async handleBtnpopupClick() {
613
+ // Invalidate any in-flight run and stop audio immediately.
614
+ await this.cancelBtnpopupRun();
615
+ // Start fresh run.
616
+ const nextRunId = this.btnpopupRunId;
617
+ setCancelBtnPopup(false);
618
+ await this.btnpopup(nextRunId);
619
+ }
583
620
  scaleNavbarContainer() {
584
621
  setTimeout(() => {
585
622
  const navBar = document.querySelector('.lido-dot-container');
@@ -624,7 +661,7 @@ export class LidoHome {
624
661
  console.log('Current Target:', event.currentTarget); // Where the onClick is bound
625
662
  console.log('✅ Button clicked - nextBtn action triggered');
626
663
  executeActions("this.nextBtn='true'", event.currentTarget);
627
- } }, h("lido-image", { src: this.navBarIcons.next }))), h("div", { id: "main-audio", class: "popup-button", onClick: () => this.btnpopup() }, h("lido-image", { visible: "true", src: this.navBarIcons.speak }))));
664
+ } }, h("lido-image", { src: this.navBarIcons.next }))), h("div", { id: "main-audio", class: "popup-button", onClick: () => this.handleBtnpopupClick() }, h("lido-image", { visible: "true", src: this.navBarIcons.speak }))));
628
665
  }
629
666
  /**
630
667
  * Jumps to a specific container based on the index of the dot clicked.
@@ -800,9 +800,12 @@ export async function onClickDropOrDragElement(element, type) {
800
800
  const selectedDropElement = type === 'drop' ? element : document.querySelector("[type='drop'].highlight-element");
801
801
  const selectedDragElement = type === 'drag' ? element : document.querySelector("[type='drag'].highlight-element");
802
802
  if (!selectedDropElement || element.classList.contains("dropped")) {
803
+ console.log("hello");
803
804
  onClickDragElement(element);
804
805
  return;
805
806
  }
807
+ if (element.classList.contains("drop-element"))
808
+ return;
806
809
  if (selectedDropElement && selectedDragElement) {
807
810
  if (selectedDragElement.getAttribute('drop-to'))
808
811
  return;