@cpzxrobot/sdk 1.2.53 → 1.2.55
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/index.js +45 -25
- package/dist/user_gateway.js +1 -0
- package/index.ts +44 -27
- package/package.json +1 -1
- package/user_gateway.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -415,25 +415,41 @@ class Cpzxrobot {
|
|
|
415
415
|
}
|
|
416
416
|
this.resolveReady(this.axios);
|
|
417
417
|
});
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
//
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
418
|
+
if (!Cpzxrobot.factorySelectorLoaded) {
|
|
419
|
+
Cpzxrobot.factorySelectorLoaded = true;
|
|
420
|
+
//@ts-ignore
|
|
421
|
+
Promise.resolve().then(() => __importStar(require('https://webc.cpzxrobot.com/webc/factory-selector.js'))).then(() => {
|
|
422
|
+
//insert cpzxrobot_factory_selector into body
|
|
423
|
+
const div = document.createElement('cpzxrobot-factory-selector');
|
|
424
|
+
div.setAttribute('selector-style', 'float-button');
|
|
425
|
+
document.body.appendChild(div);
|
|
426
|
+
//register onUnitChanged and onFactoryChanged on div
|
|
427
|
+
div.addEventListener('unitChanged', (e) => {
|
|
428
|
+
var _a;
|
|
429
|
+
var ce = e;
|
|
430
|
+
this.user.selectedUnit = ce.detail;
|
|
431
|
+
// @ts-ignore
|
|
432
|
+
var fn = (_a = window._notifyUnitChanged) !== null && _a !== void 0 ? _a : ((detail) => {
|
|
433
|
+
console.log('Unit changed:', detail);
|
|
434
|
+
});
|
|
435
|
+
fn(ce.detail);
|
|
436
|
+
});
|
|
437
|
+
div.addEventListener('factoryChanged', (e) => {
|
|
438
|
+
var _a;
|
|
439
|
+
var ce = e;
|
|
440
|
+
this.user.selectedFarm = ce.detail;
|
|
441
|
+
// @ts-ignore
|
|
442
|
+
var fn = (_a = window._notifyFactoryChanged) !== null && _a !== void 0 ? _a : ((detail) => {
|
|
443
|
+
console.log('Factory changed:', detail);
|
|
444
|
+
});
|
|
445
|
+
fn(ce.detail);
|
|
446
|
+
});
|
|
447
|
+
})
|
|
448
|
+
.catch(err => {
|
|
449
|
+
console.error('Failed to load factory-selector module:', err);
|
|
450
|
+
Cpzxrobot.factorySelectorLoaded = false;
|
|
432
451
|
});
|
|
433
|
-
}
|
|
434
|
-
.catch(err => {
|
|
435
|
-
console.error('Failed to load factory-selector module:', err);
|
|
436
|
-
});
|
|
452
|
+
}
|
|
437
453
|
return;
|
|
438
454
|
}
|
|
439
455
|
else {
|
|
@@ -507,7 +523,7 @@ class Cpzxrobot {
|
|
|
507
523
|
}
|
|
508
524
|
}
|
|
509
525
|
exports.Cpzxrobot = Cpzxrobot;
|
|
510
|
-
|
|
526
|
+
Cpzxrobot.factorySelectorLoaded = false;
|
|
511
527
|
function default_1(args = {
|
|
512
528
|
devAuth: "",
|
|
513
529
|
appCode: "",
|
|
@@ -523,15 +539,19 @@ function default_1(args = {
|
|
|
523
539
|
name: "",
|
|
524
540
|
},
|
|
525
541
|
}) {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
542
|
+
// @ts-ignore
|
|
543
|
+
var instance = window.single_cpzxrobot_instance;
|
|
544
|
+
if (!instance) {
|
|
545
|
+
instance = new Cpzxrobot(args.appCode);
|
|
546
|
+
// @ts-ignore
|
|
547
|
+
window.single_cpzxrobot_instance = instance;
|
|
548
|
+
instance.setAuth(args.devAuth, args.baseURL);
|
|
529
549
|
if (args.selectedFarm) {
|
|
530
|
-
|
|
550
|
+
instance.user.selectedFarm = args.selectedFarm;
|
|
531
551
|
}
|
|
532
552
|
if (args.selectedUnit) {
|
|
533
|
-
|
|
553
|
+
instance.user.selectedUnit = args.selectedUnit;
|
|
534
554
|
}
|
|
535
555
|
}
|
|
536
|
-
return
|
|
556
|
+
return instance;
|
|
537
557
|
}
|
package/dist/user_gateway.js
CHANGED
package/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { QuotationGateway } from "./quotation_gateway";
|
|
|
24
24
|
import { AiGateway } from "./ai_gateway";
|
|
25
25
|
|
|
26
26
|
export class Cpzxrobot {
|
|
27
|
+
private static factorySelectorLoaded = false;
|
|
27
28
|
device: DeviceGateway;
|
|
28
29
|
pigfarm: PigfarmGateway = new PigfarmGateway(this);
|
|
29
30
|
chickenfarm: ChickenFarmGateway = new ChickenFarmGateway(this);
|
|
@@ -443,26 +444,40 @@ export class Cpzxrobot {
|
|
|
443
444
|
}
|
|
444
445
|
this.resolveReady(this.axios);
|
|
445
446
|
});
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
//
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
447
|
+
if (!Cpzxrobot.factorySelectorLoaded) {
|
|
448
|
+
Cpzxrobot.factorySelectorLoaded = true;
|
|
449
|
+
//@ts-ignore
|
|
450
|
+
import('https://webc.cpzxrobot.com/webc/factory-selector.js')
|
|
451
|
+
.then(() => {
|
|
452
|
+
//insert cpzxrobot_factory_selector into body
|
|
453
|
+
const div = document.createElement('cpzxrobot-factory-selector');
|
|
454
|
+
div.setAttribute('selector-style', 'float-button');
|
|
455
|
+
document.body.appendChild(div);
|
|
456
|
+
//register onUnitChanged and onFactoryChanged on div
|
|
457
|
+
div.addEventListener('unitChanged', (e) => {
|
|
458
|
+
var ce = e as CustomEvent;
|
|
459
|
+
this.user.selectedUnit = ce.detail;
|
|
460
|
+
// @ts-ignore
|
|
461
|
+
var fn = window._notifyUnitChanged ?? ((detail) => {
|
|
462
|
+
console.log('Unit changed:', detail);
|
|
463
|
+
});
|
|
464
|
+
fn(ce.detail);
|
|
465
|
+
});
|
|
466
|
+
div.addEventListener('factoryChanged', (e) => {
|
|
467
|
+
var ce = e as CustomEvent;
|
|
468
|
+
this.user.selectedFarm = ce.detail;
|
|
469
|
+
// @ts-ignore
|
|
470
|
+
var fn = window._notifyFactoryChanged ?? ((detail) => {
|
|
471
|
+
console.log('Factory changed:', detail);
|
|
472
|
+
});
|
|
473
|
+
fn(ce.detail);
|
|
474
|
+
});
|
|
475
|
+
})
|
|
476
|
+
.catch(err => {
|
|
477
|
+
console.error('Failed to load factory-selector module:', err);
|
|
478
|
+
Cpzxrobot.factorySelectorLoaded = false;
|
|
461
479
|
});
|
|
462
|
-
|
|
463
|
-
.catch(err => {
|
|
464
|
-
console.error('Failed to load factory-selector module:', err);
|
|
465
|
-
});
|
|
480
|
+
}
|
|
466
481
|
return;
|
|
467
482
|
} else {
|
|
468
483
|
//if url has access_token and app_code, use it
|
|
@@ -533,8 +548,6 @@ export class Cpzxrobot {
|
|
|
533
548
|
}
|
|
534
549
|
}
|
|
535
550
|
|
|
536
|
-
let _instance!: Cpzxrobot;
|
|
537
|
-
|
|
538
551
|
export default function (
|
|
539
552
|
args: {
|
|
540
553
|
devAuth: string;
|
|
@@ -558,17 +571,21 @@ export default function (
|
|
|
558
571
|
},
|
|
559
572
|
}
|
|
560
573
|
): Cpzxrobot {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
574
|
+
// @ts-ignore
|
|
575
|
+
var instance = window.single_cpzxrobot_instance;
|
|
576
|
+
if (!instance) {
|
|
577
|
+
instance = new Cpzxrobot(args.appCode);
|
|
578
|
+
// @ts-ignore
|
|
579
|
+
window.single_cpzxrobot_instance = instance;
|
|
580
|
+
instance.setAuth(args.devAuth, args.baseURL);
|
|
564
581
|
if (args.selectedFarm) {
|
|
565
|
-
|
|
582
|
+
instance.user.selectedFarm = args.selectedFarm;
|
|
566
583
|
}
|
|
567
584
|
if (args.selectedUnit) {
|
|
568
|
-
|
|
585
|
+
instance.user.selectedUnit = args.selectedUnit;
|
|
569
586
|
}
|
|
570
587
|
}
|
|
571
|
-
return
|
|
588
|
+
return instance;
|
|
572
589
|
}
|
|
573
590
|
|
|
574
591
|
export { type ElectricMeterRate };
|
package/package.json
CHANGED