@denevads/dnv-smo 1.0.21 → 1.0.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@denevads/dnv-smo",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "SMO module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/smo.ts CHANGED
@@ -49,7 +49,7 @@ export class SMO {
49
49
  if(window.objJS){
50
50
  // @ts-ignore
51
51
  window.sendToIframefromNet = (target, iframeID, objData) => {
52
- console.log("sendToIframefromNet->",target);
52
+ console.log("sendToIframefromNet->",JSON.stringify(target));
53
53
  switch (target) {
54
54
  case "SMO.setDatasource":
55
55
  this.events.setDatasource.next(objData)
@@ -58,44 +58,7 @@ export class SMO {
58
58
  this.events.checkHealthPrinter.next(objData);
59
59
  break;
60
60
  }
61
- // @ts-ignore
62
- window.parent.postMessage = (target,objData,idSmo)=> {
63
- switch (target.target) {
64
- case "Dnv.smoCallbacks.onSmoLoad":
65
- // @ts-ignore
66
- window.objJS.onSmoLoad();
67
- break;
68
61
 
69
- case "Dnv.smoCallbacks.printTextLine":
70
- // @ts-ignore
71
- window.objJS.printTextLine(objData.txt);
72
- break;
73
- case "Dnv.smoCallbacks.printBarcode":
74
- // @ts-ignore
75
- window.objJS.printBarcode(objData.code, objData.width, objData.height);
76
- break;
77
- case "Dnv.smoCallbacks.cutPaper":
78
- // @ts-ignore
79
- window.objJS.cutPaper(objData.percent);
80
- break;
81
- case "Dnv.smoCallbacks.printImage":
82
- // @ts-ignore
83
- window.objJS.printImage(idSmo, objData.image);
84
- break;
85
- case "Dnv.smoCallbacks.checkHealthPrinter":
86
- console.log('llamo a checkhealthprinter');
87
- // @ts-ignore
88
-
89
- window.objJS.checkHealthPrinter(idSmo);
90
- break;
91
- case "Dnv.smoCallbacks.checkHealth":
92
- // @ts-ignore
93
- window.objJS.checkHealth();
94
- break;
95
-
96
-
97
- }
98
- }
99
62
 
100
63
  }
101
64
 
@@ -315,7 +278,7 @@ class SmoEvents{
315
278
  public getRecursosRelleno: Subject<GetRecursosRelleno> = new Subject<GetRecursosRelleno>();
316
279
  public getVariableStorage: Subject<variable> = new Subject<variable>();
317
280
  public checkHealth: Subject<string> = new Subject<string>();
318
- public checkHealthPrinter: Subject<String> = new Subject<String>();
281
+ public checkHealthPrinter: Subject<string> = new Subject<string>();
319
282
  constructor(smo:SMO){}
320
283
  }
321
284
  class smoCallBacks{
@@ -324,14 +287,14 @@ class smoCallBacks{
324
287
  this.smo =_smo;
325
288
  }
326
289
  public onSmoLoad():void {
327
- window.parent.postMessage({
290
+ this.smo.utils.sendToParent({
328
291
  target: "Dnv.smoCallbacks.onSmoLoad",
329
292
  objData: undefined,
330
293
  idSmo: this.smo.id
331
294
  }, "*");
332
295
  }
333
296
  public onSmoReady():void {
334
- window.parent.postMessage({
297
+ this.smo.utils.sendToParent({
335
298
  target: "Dnv.smoCallbacks.onSmoReady",
336
299
  objData: undefined,
337
300
  idSmo: this.smo.id
@@ -355,7 +318,7 @@ class smoCallBacks{
355
318
  console.error(msn);
356
319
  }
357
320
  if (window.parent != window) {
358
- window.parent.postMessage({
321
+ this.smo.utils.sendToParent({
359
322
  target: "Dnv.smoCallbacks.smoLog",
360
323
  objData: {
361
324
  level: level,
@@ -367,7 +330,7 @@ class smoCallBacks{
367
330
 
368
331
  }
369
332
  public smoAlarma(msn:string, level:AlarmaLevel):void {
370
- window.parent.postMessage({
333
+ this.smo.utils.sendToParent({
371
334
  target: "Dnv.smoCallbacks.smoAlarma",
372
335
  objData: {
373
336
  level: level,
@@ -377,7 +340,7 @@ class smoCallBacks{
377
340
  }, "*");
378
341
  }
379
342
  public smoLogStash(msn:string):void {
380
- window.parent.postMessage({
343
+ this.smo.utils.sendToParent({
381
344
  target: "Dnv.smoCallbacks.smoLogStash",
382
345
  objData: {
383
346
  txt: msn
@@ -386,7 +349,7 @@ class smoCallBacks{
386
349
  }, "*");
387
350
  }
388
351
  public smoLogNowShowing(msn:any):void {
389
- window.parent.postMessage({
352
+ this.smo.utils.sendToParent({
390
353
  target: "Dnv.smoCallbacks.smoNowShowing",
391
354
  objData: msn,
392
355
  idSmo: this.smo.id
@@ -394,7 +357,7 @@ class smoCallBacks{
394
357
  }
395
358
  public reiniciarDispositivo(msn:string):void {
396
359
  //Permite reiniciar el player, proporcionando una razón para el reinicio. Solo Player HTML5
397
- window.parent.postMessage({
360
+ this.smo.utils.sendToParent({
398
361
  target: "Dnv.smoCallbacks.reiniciarDispositivo",
399
362
  objData: {
400
363
  txt: msn // Razón del reinicio
@@ -404,7 +367,7 @@ class smoCallBacks{
404
367
  }
405
368
  urlNext():void {
406
369
  //Permite avanzar plantilla. Solo si Reloj Maestro activado.
407
- window.parent.postMessage({
370
+ this.smo.utils.sendToParent({
408
371
  target: "Dnv.smoCallbacks.urlNext",
409
372
  objData: undefined,
410
373
  idSmo: this.smo.id
@@ -412,7 +375,7 @@ class smoCallBacks{
412
375
  }
413
376
  exitInteractivity():void {
414
377
  //Para canales interactivos, vuelve al canal de reposo. Solo Android y Player PC.
415
- window.parent.postMessage({
378
+ this.smo.utils.sendToParent({
416
379
  target: "Dnv.smoCallbacks.exitInteractivity",
417
380
  objData: undefined,
418
381
  idSmo: this.smo.id
@@ -428,7 +391,7 @@ class smoCallBacks{
428
391
  /* NOT IMPLEMENTED */
429
392
  }
430
393
  setVariable(variable:string, valor:string) {
431
- window.parent.postMessage({
394
+ this.smo.utils.sendToParent({
432
395
  target: "Dnv.smoCallbacks.setVariable",
433
396
  objData: {
434
397
  variable: variable,
@@ -438,7 +401,7 @@ class smoCallBacks{
438
401
  }, "*");
439
402
  }
440
403
  getVariable(variable:string):void {
441
- window.parent.postMessage({
404
+ this.smo.utils.sendToParent({
442
405
  target: "Dnv.smoCallbacks.getVariable",
443
406
  objData: {
444
407
  variable: variable
@@ -447,15 +410,16 @@ class smoCallBacks{
447
410
  }, "*");
448
411
  /* MIRAR SMO.getVariable */
449
412
  }
413
+
450
414
  getFile(file:string):void {
451
- parent.postMessage({
415
+ this.smo.utils.sendToParent({
452
416
  target: "Dnv.smoCallbacks.getFile",
453
417
  objData: file,
454
418
  idSmo: this.smo.id
455
419
  }, "*");
456
420
  }
457
421
  setLocalData(variable:string, valor:string):void {
458
- parent.postMessage({
422
+ this.smo.utils.sendToParent({
459
423
  target: "Dnv.smoCallbacks.setLocalData",
460
424
  objData: {
461
425
  nameData: variable,
@@ -465,7 +429,7 @@ class smoCallBacks{
465
429
  }, "*");
466
430
  }
467
431
  getLocalData(variable:string):void {
468
- parent.postMessage({
432
+ this.smo.utils.sendToParent({
469
433
  target: "Dnv.smoCallbacks.getLocalData",
470
434
  objData: variable, // nameData
471
435
  idSmo: this.smo.id
@@ -473,8 +437,7 @@ class smoCallBacks{
473
437
  /* MIRAR SMO.setDatasource */
474
438
  }
475
439
  getCurrentStream():void {
476
-
477
- parent.postMessage({
440
+ this.smo.utils.sendToParent({
478
441
  target: "Dnv.smoCallbacks.getCurrentStream",
479
442
  objData: undefined,
480
443
  idSmo: this.smo.id
@@ -482,21 +445,21 @@ class smoCallBacks{
482
445
  /* MIRAR SMO.setCurrentStream' */
483
446
  }
484
447
  finAviso(id:string):void {
485
- parent.postMessage({
448
+ this.smo.utils.sendToParent({
486
449
  target: "Dnv.smoCallbacks.finAviso",
487
450
  objData: id, // id del aviso
488
451
  idSmo: this.smo.id
489
452
  }, "*");
490
453
  }
491
454
  refreshDatasource(codigo:string):void {
492
- parent.postMessage({
455
+ this.smo.utils.sendToParent({
493
456
  target: "Dnv.smoCallbacks.refreshDatasource",
494
457
  objData: codigo, // Codigo del datasource
495
458
  idSmo: this.smo.id
496
459
  }, "*");
497
460
  }
498
461
  getLocation():void {
499
- parent.postMessage({
462
+ this.smo.utils.sendToParent({
500
463
  target: "Dnv.smoCallbacks.getLocation",
501
464
  objData: undefined,
502
465
  idSmo: this.smo.id
@@ -504,7 +467,7 @@ class smoCallBacks{
504
467
  /* MIRAR SMO.infoCurrentLocation */
505
468
  }
506
469
  getSalidaData(data:string):void {
507
- parent.postMessage({
470
+ this.smo.utils.sendToParent({
508
471
  target: "Dnv.smoCallbacks.getSalidaData",
509
472
  objData: data, // Nombre del "data" que solicita. El player recibe ese string y hace un select case del mismo para devolver un json con datos al smo\html5 que le ha invocado.
510
473
  idSmo: this.smo.id
@@ -516,7 +479,7 @@ class smoCallBacks{
516
479
  funcion: "", // Nombre de la función que se debe ejecutar
517
480
  params: "" // Parámetros que debemos enviarle a la funcion. sin separadores ni nada, un string y se usa como tal. Solo esta implementada en un caso y se usa como tal sin parsear ni nada
518
481
  } */
519
- parent.postMessage({
482
+ this.smo.utils.sendToParent({
520
483
  target: "Dnv.smoCallbacks.ejecutaFuncion",
521
484
  objData: data,
522
485
  idSmo: this.smo.id
@@ -525,7 +488,7 @@ class smoCallBacks{
525
488
  addObserver(data:string):void {
526
489
  /*data ="fruta"
527
490
  */
528
- parent.postMessage({
491
+ this.smo.utils.sendToParent({
529
492
  target: "Dnv.smoCallbacks.addObserver",
530
493
  objData: data,
531
494
  idSmo: this.smo.id
@@ -536,7 +499,7 @@ class smoCallBacks{
536
499
  destino: "fruta",
537
500
  value: "{'fruta':'manzana', 'color':'roja'}"
538
501
  } */
539
- parent.postMessage({
502
+ this.smo.utils.sendToParent({
540
503
  target: "Dnv.smoCallbacks.notify",
541
504
  objData: data,
542
505
  idSmo: this.smo.id
@@ -544,24 +507,24 @@ class smoCallBacks{
544
507
  }, "*");
545
508
  }
546
509
  playOnceChannelByTrigger(trigger:string):void {
547
- parent.postMessage({
510
+ this.smo.utils.sendToParent({
548
511
  target: "Dnv.smoCallbacks.playOnceChannelByTrigger",
549
512
  objData: { triggerCanal: trigger },
550
513
  idSmo: this.smo.id
551
514
  }, "*");
552
515
  }
553
516
  stopPlayOnceChannelByTrigger():void {
554
- parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannelByTrigger", objData: {}, idSmo: this.smo.id }, "*");
517
+ this.smo.utils.sendToParent({ target: "Dnv.smoCallbacks.stopPlayOnceChannelByTrigger", objData: {}, idSmo: this.smo.id }, "*");
555
518
  }
556
519
  playOnceChannel(codigoCanal:string):void {
557
- parent.postMessage({ target: "Dnv.smoCallbacks.playOnceChannel", objData: { codigoCanal: codigoCanal, params: "PLAYONCE_CHANNEL|" + codigoCanal }, idSmo: this.smo.id }, "*");
520
+ this.smo.utils.sendToParent({ target: "Dnv.smoCallbacks.playOnceChannel", objData: { codigoCanal: codigoCanal, params: "PLAYONCE_CHANNEL|" + codigoCanal }, idSmo: this.smo.id }, "*");
558
521
  }
559
522
  stopPlayChannel():void {
560
- parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
523
+ this.smo.utils.sendToParent({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
561
524
  }
562
525
  editWrapperStyle(obj: any):void{
563
526
  /*{"posX": "0px","posY": "0px","alto": "0px","ancho": "0px","overflow": "hidden","scale": 0.1,"zindex": 0.1,"opacidad": 0.1,"isMaestro": true,duracionTransition: "1s", transitionTiming: "lineal", css: string} */
564
- parent.postMessage({
527
+ this.smo.utils.sendToParent({
565
528
  target: "Dnv.smoCallbacks.editWrapperStyle",
566
529
  objData: obj,
567
530
  idSmo: this.smo.id
@@ -569,7 +532,7 @@ class smoCallBacks{
569
532
  }
570
533
  getRecursosByCodigo(codigos: any):void{
571
534
  /** ["123456","654321"] */
572
- parent.postMessage({
535
+ this.smo.utils.sendToParent({
573
536
  target: "Dnv.smoCallbacks.getRecursosByCodigo",
574
537
  objData: {
575
538
  recursos : codigos
@@ -578,25 +541,25 @@ class smoCallBacks{
578
541
  }, "*");
579
542
  }
580
543
  getRecursos():void{
581
- parent.postMessage({
544
+ this.smo.utils.sendToParent({
582
545
  target: "Dnv.smoCallbacks.getRecursos",
583
546
  idSmo: this.smo.id
584
547
  }, "*");
585
548
  }
586
549
  getRecursosDefault():void{
587
- parent.postMessage({
550
+ this.smo.utils.sendToParent({
588
551
  target: "Dnv.smoCallbacks.getRecursosDefault",
589
552
  idSmo: this.smo.id
590
553
  }, "*");
591
554
  }
592
555
  getRecursosRelleno():void{
593
- parent.postMessage({
556
+ this.smo.utils.sendToParent({
594
557
  target: "Dnv.smoCallbacks.getRecursosRelleno",
595
558
  idSmo: this.smo.id
596
559
  }, "*");
597
560
  }
598
561
  setVariableStorage(variable:string, valor:string) {
599
- window.parent.postMessage({
562
+ this.smo.utils.sendToParent({
600
563
  target: "Dnv.smoCallbacks.setVariableStorage",
601
564
  objData: {
602
565
  variable: variable,
@@ -606,7 +569,7 @@ class smoCallBacks{
606
569
  }, "*");
607
570
  }
608
571
  getVariableStorage(variable:string):void {
609
- window.parent.postMessage({
572
+ this.smo.utils.sendToParent({
610
573
  target: "Dnv.smoCallbacks.getVariableStorage",
611
574
  objData: {
612
575
  variable: variable
@@ -616,7 +579,7 @@ class smoCallBacks{
616
579
  /* MIRAR SMO.getVariable */
617
580
  }
618
581
  printTextLine(txt:string):void{
619
- window.parent.postMessage({
582
+ this.smo.utils.sendToParent({
620
583
  target: "Dnv.smoCallbacks.printTextLine",
621
584
  objData: {
622
585
  txt: txt
@@ -625,7 +588,7 @@ class smoCallBacks{
625
588
  }, "*");
626
589
  }
627
590
  printBarcode(code:string, width:number, height:number):void{
628
- window.parent.postMessage({
591
+ this.smo.utils.sendToParent({
629
592
  target: "Dnv.smoCallbacks.printBarcode",
630
593
  objData: {
631
594
  code: code,
@@ -636,7 +599,7 @@ class smoCallBacks{
636
599
  }, "*");
637
600
  }
638
601
  cutPaper(percent:number):void{
639
- window.parent.postMessage({
602
+ this.smo.utils.sendToParent({
640
603
  target: "Dnv.smoCallbacks.cutPaper",
641
604
  objData: {
642
605
  percent: percent
@@ -645,19 +608,19 @@ class smoCallBacks{
645
608
  }, "*");
646
609
  }
647
610
  checkHealth(){
648
- window.parent.postMessage({
649
- target: "Dnv.smoCallbacks.checkHealth",
650
- idSmo: this.smo.id
651
- }, "*");
611
+ this.smo.utils.sendToParent({
612
+ target: "Dnv.smoCallbacks.checkHealth",
613
+ idSmo: this.smo.id
614
+ }, "*");
652
615
  }
653
616
  checkHealthPrinter(){
654
- window.parent.postMessage({
617
+ this.smo.utils.sendToParent({
655
618
  target: "Dnv.smoCallbacks.checkHealthPrinter",
656
619
  idSmo: this.smo.id
657
620
  }, "*");
658
621
  }
659
622
  printImage(image:string):void{
660
- window.parent.postMessage({
623
+ this.smo.utils.sendToParent({
661
624
  target: "Dnv.smoCallbacks.printImage",
662
625
  objData: {
663
626
  image: image
@@ -689,6 +652,88 @@ class Utils{
689
652
  let rejsn = JSON.stringify(js_obj, undefined, 2).replace(/(\\t|\\r|\\n)/g, '').replace(/"",[\n\t\r\s]+""[,]*/g, '').replace(/(\n[\t\s\r]*\n)/g, '').replace(/[\s\t]{2,}""[,]{0,1}/g, '').replace(/"[\s\t]{1,}"[,]{0,1}/g, '').replace(/\[[\t\s]*\]/g, '""');
690
653
  return (rejsn.indexOf('"parsererror": {') == -1) ? rejsn : 'Invalid XML format';
691
654
  }
655
+ sendToParent(obj:any,dest:string){
656
+ console.log('sendToParent->',JSON.stringify(obj));
657
+ //@ts-ignore
658
+ if(window.objJS){
659
+ switch (obj.target) {
660
+ case "Dnv.smoCallbacks.onSmoLoad":
661
+ // @ts-ignore
662
+ window.objJS.onSmoLoad();
663
+ break;
664
+
665
+ case "Dnv.smoCallbacks.printTextLine":
666
+ // @ts-ignore
667
+ window.objJS.printTextLine(obj.txt);
668
+ break;
669
+ case "Dnv.smoCallbacks.printBarcode":
670
+ // @ts-ignore
671
+ window.objJS.printBarcode(obj.code, obj.width, obj.height);
672
+ break;
673
+ case "Dnv.smoCallbacks.cutPaper":
674
+ // @ts-ignore
675
+ window.objJS.cutPaper(obj.percent);
676
+ break;
677
+ case "Dnv.smoCallbacks.printImage":
678
+ // @ts-ignore
679
+ window.objJS.printImage(obj.idSmo, obj.image);
680
+ break;
681
+ case "Dnv.smoCallbacks.checkHealthPrinter":
682
+ console.log('llamo a checkhealthprinter');
683
+ // @ts-ignore
684
+ window.objJS.checkHealthPrinter(obj.idSmo);
685
+ break;
686
+ case "Dnv.smoCallbacks.checkHealth":
687
+ // @ts-ignore
688
+ window.objJS.checkHealth();
689
+ break;
690
+ case "Dnv.smoCallbacks.getFile":
691
+ // @ts-ignore
692
+ window.objJS.getFile(dest,obj.objData);
693
+ break;
694
+ }
695
+ return;
696
+ }
697
+ /* // @ts-ignore
698
+ window.parent.postMessage = (target,objData,idSmo)=> {
699
+ switch (target.target) {
700
+ case "Dnv.smoCallbacks.onSmoLoad":
701
+ // @ts-ignore
702
+ window.objJS.onSmoLoad();
703
+ break;
704
+
705
+ case "Dnv.smoCallbacks.printTextLine":
706
+ // @ts-ignore
707
+ window.objJS.printTextLine(objData.txt);
708
+ break;
709
+ case "Dnv.smoCallbacks.printBarcode":
710
+ // @ts-ignore
711
+ window.objJS.printBarcode(objData.code, objData.width, objData.height);
712
+ break;
713
+ case "Dnv.smoCallbacks.cutPaper":
714
+ // @ts-ignore
715
+ window.objJS.cutPaper(objData.percent);
716
+ break;
717
+ case "Dnv.smoCallbacks.printImage":
718
+ // @ts-ignore
719
+ window.objJS.printImage(idSmo, objData.image);
720
+ break;
721
+ case "Dnv.smoCallbacks.checkHealthPrinter":
722
+ console.log('llamo a checkhealthprinter');
723
+ // @ts-ignore
724
+
725
+ window.objJS.checkHealthPrinter(idSmo);
726
+ break;
727
+ case "Dnv.smoCallbacks.checkHealth":
728
+ // @ts-ignore
729
+ window.objJS.checkHealth();
730
+ break;
731
+
732
+
733
+ }
734
+ }*/
735
+ window.parent.postMessage(obj, dest);
736
+ }
692
737
  setJsonObj(xml: any) {
693
738
  let js_obj = {} as any;
694
739
  if (xml.nodeType == 1) { // Element