@worktile/planet 11.0.0 → 12.1.2

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.
Files changed (93) hide show
  1. package/application/planet-application-loader.d.ts.map +1 -1
  2. package/application/planet-application-loader.ngfactory.d.ts.map +1 -0
  3. package/application/planet-application-ref.d.ts +13 -10
  4. package/application/planet-application-ref.d.ts.map +1 -1
  5. package/application/planet-application.service.d.ts +1 -1
  6. package/application/planet-application.service.d.ts.map +1 -1
  7. package/application/planet-application.service.ngfactory.d.ts.map +1 -0
  8. package/application/portal-application.d.ts +6 -6
  9. package/application/portal-application.d.ts.map +1 -1
  10. package/assets-loader.d.ts +11 -2
  11. package/assets-loader.d.ts.map +1 -1
  12. package/assets-loader.ngfactory.d.ts.map +1 -0
  13. package/bundles/worktile-planet.umd.js +851 -58
  14. package/bundles/worktile-planet.umd.js.map +1 -1
  15. package/component/planet-component-loader.d.ts.map +1 -1
  16. package/component/planet-component-loader.ngfactory.d.ts.map +1 -0
  17. package/empty/empty.component.ngfactory.d.ts.map +1 -0
  18. package/esm2015/application/planet-application-loader.js +15 -10
  19. package/esm2015/application/planet-application-ref.js +29 -18
  20. package/esm2015/application/planet-application.service.js +1 -1
  21. package/esm2015/application/portal-application.js +1 -1
  22. package/esm2015/assets-loader.js +60 -8
  23. package/esm2015/component/planet-component-loader.js +3 -5
  24. package/esm2015/debug.js +2 -2
  25. package/esm2015/global-planet.js +6 -3
  26. package/esm2015/helpers.js +6 -3
  27. package/esm2015/planet.class.js +1 -1
  28. package/esm2015/planet.js +4 -3
  29. package/esm2015/sandbox/constants.js +7 -0
  30. package/esm2015/sandbox/exec.js +15 -0
  31. package/esm2015/sandbox/index.js +20 -0
  32. package/esm2015/sandbox/proxy/patches/document.js +12 -0
  33. package/esm2015/sandbox/proxy/patches/eventListener.js +41 -0
  34. package/esm2015/sandbox/proxy/patches/index.js +11 -0
  35. package/esm2015/sandbox/proxy/patches/storage.js +40 -0
  36. package/esm2015/sandbox/proxy/patches/timer.js +43 -0
  37. package/esm2015/sandbox/proxy/proxies/common.js +132 -0
  38. package/esm2015/sandbox/proxy/proxies/document.js +126 -0
  39. package/esm2015/sandbox/proxy/proxies/window.js +155 -0
  40. package/esm2015/sandbox/proxy/proxy-sandbox.js +49 -0
  41. package/esm2015/sandbox/proxy/types.js +2 -0
  42. package/esm2015/sandbox/sandbox.js +7 -0
  43. package/esm2015/sandbox/snapshot/snapshot-sandbox.js +12 -0
  44. package/esm2015/sandbox/types.js +2 -0
  45. package/fesm2015/worktile-planet.js +763 -45
  46. package/fesm2015/worktile-planet.js.map +1 -1
  47. package/global-event-dispatcher.ngfactory.d.ts.map +1 -0
  48. package/global-planet.d.ts +3 -3
  49. package/global-planet.d.ts.map +1 -1
  50. package/helpers.d.ts +3 -2
  51. package/helpers.d.ts.map +1 -1
  52. package/module.ngfactory.d.ts.map +1 -0
  53. package/package.json +5 -5
  54. package/planet.class.d.ts +1 -0
  55. package/planet.class.d.ts.map +1 -1
  56. package/planet.d.ts +1 -1
  57. package/planet.d.ts.map +1 -1
  58. package/planet.ngfactory.d.ts.map +1 -0
  59. package/sandbox/constants.d.ts +7 -0
  60. package/sandbox/constants.d.ts.map +1 -0
  61. package/sandbox/exec.d.ts +3 -0
  62. package/sandbox/exec.d.ts.map +1 -0
  63. package/sandbox/index.d.ts +7 -0
  64. package/sandbox/index.d.ts.map +1 -0
  65. package/sandbox/proxy/patches/document.d.ts +3 -0
  66. package/sandbox/proxy/patches/document.d.ts.map +1 -0
  67. package/sandbox/proxy/patches/eventListener.d.ts +3 -0
  68. package/sandbox/proxy/patches/eventListener.d.ts.map +1 -0
  69. package/sandbox/proxy/patches/index.d.ts +3 -0
  70. package/sandbox/proxy/patches/index.d.ts.map +1 -0
  71. package/sandbox/proxy/patches/storage.d.ts +15 -0
  72. package/sandbox/proxy/patches/storage.d.ts.map +1 -0
  73. package/sandbox/proxy/patches/timer.d.ts +3 -0
  74. package/sandbox/proxy/patches/timer.d.ts.map +1 -0
  75. package/sandbox/proxy/proxies/common.d.ts +13 -0
  76. package/sandbox/proxy/proxies/common.d.ts.map +1 -0
  77. package/sandbox/proxy/proxies/document.d.ts +14 -0
  78. package/sandbox/proxy/proxies/document.d.ts.map +1 -0
  79. package/sandbox/proxy/proxies/window.d.ts +13 -0
  80. package/sandbox/proxy/proxies/window.d.ts.map +1 -0
  81. package/sandbox/proxy/proxy-sandbox.d.ts +16 -0
  82. package/sandbox/proxy/proxy-sandbox.d.ts.map +1 -0
  83. package/sandbox/proxy/types.d.ts +14 -0
  84. package/sandbox/proxy/types.d.ts.map +1 -0
  85. package/sandbox/sandbox.d.ts +12 -0
  86. package/sandbox/sandbox.d.ts.map +1 -0
  87. package/sandbox/snapshot/snapshot-sandbox.d.ts +9 -0
  88. package/sandbox/snapshot/snapshot-sandbox.d.ts.map +1 -0
  89. package/sandbox/types.d.ts +2 -0
  90. package/sandbox/types.d.ts.map +1 -0
  91. package/worktile-planet.metadata.json +1 -1
  92. package/bundles/worktile-planet.umd.min.js +0 -16
  93. package/bundles/worktile-planet.umd.min.js.map +0 -1
@@ -60,14 +60,14 @@
60
60
  }
61
61
  function getTagNameByTemplate(template) {
62
62
  var element = createElementByTemplate(template);
63
- return element ? element.nodeName : null;
63
+ return element ? element.nodeName : '';
64
64
  }
65
65
  function createElementByTemplate(template) {
66
66
  if (!template) {
67
67
  return null;
68
68
  }
69
69
  var element = document.createRange().createContextualFragment(template).firstChild;
70
- if (element.nodeType === ELEMENT_NODE_TYPE) {
70
+ if (element && element.nodeType === ELEMENT_NODE_TYPE) {
71
71
  return element;
72
72
  }
73
73
  else {
@@ -89,6 +89,9 @@
89
89
  var type = typeof value;
90
90
  return !!value && type === 'function';
91
91
  }
92
+ function isObject(val) {
93
+ return val && typeof val === 'object';
94
+ }
92
95
  /**
93
96
  * Get file name from path
94
97
  * 1. "main.js" => "main.js"
@@ -176,6 +179,8 @@
176
179
  return extendStatics(d, b);
177
180
  };
178
181
  function __extends(d, b) {
182
+ if (typeof b !== "function" && b !== null)
183
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
179
184
  extendStatics(d, b);
180
185
  function __() { this.constructor = d; }
181
186
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -361,11 +366,13 @@
361
366
  }
362
367
  return ar;
363
368
  }
369
+ /** @deprecated */
364
370
  function __spread() {
365
371
  for (var ar = [], i = 0; i < arguments.length; i++)
366
372
  ar = ar.concat(__read(arguments[i]));
367
373
  return ar;
368
374
  }
375
+ /** @deprecated */
369
376
  function __spreadArrays() {
370
377
  for (var s = 0, i = 0, il = arguments.length; i < il; i++)
371
378
  s += arguments[i].length;
@@ -374,7 +381,17 @@
374
381
  r[k] = a[j];
375
382
  return r;
376
383
  }
377
- ;
384
+ function __spreadArray(to, from, pack) {
385
+ if (pack || arguments.length === 2)
386
+ for (var i = 0, l = from.length, ar; i < l; i++) {
387
+ if (ar || !(i in from)) {
388
+ if (!ar)
389
+ ar = Array.prototype.slice.call(from, 0, i);
390
+ ar[i] = from[i];
391
+ }
392
+ }
393
+ return to.concat(ar || from);
394
+ }
378
395
  function __await(v) {
379
396
  return this instanceof __await ? (this.v = v, this) : new __await(v);
380
397
  }
@@ -439,18 +456,719 @@
439
456
  function __importDefault(mod) {
440
457
  return (mod && mod.__esModule) ? mod : { default: mod };
441
458
  }
442
- function __classPrivateFieldGet(receiver, privateMap) {
443
- if (!privateMap.has(receiver)) {
444
- throw new TypeError("attempted to get private field on non-instance");
459
+ function __classPrivateFieldGet(receiver, state, kind, f) {
460
+ if (kind === "a" && !f)
461
+ throw new TypeError("Private accessor was defined without a getter");
462
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
463
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
464
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
465
+ }
466
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
467
+ if (kind === "m")
468
+ throw new TypeError("Private method is not writable");
469
+ if (kind === "a" && !f)
470
+ throw new TypeError("Private accessor was defined without a setter");
471
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
472
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
473
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
474
+ }
475
+
476
+ var PLANET_SANDBOX_WINDOW_WHITELIST = window['___PLANET_SANDBOX_WINDOW_WHITELIST___'];
477
+ var PLANET_SANDBOX_DOCUMENT_WHITELIST = window['___PLANET_SANDBOX_DOCUMENT_WHITELIST___'];
478
+ var SANDBOX_INSTANCE = Symbol.for('PLANET_SANDBOX_INSTANCE');
479
+ var RAW_NODE = Symbol.for('PLANET_RAW_NODE');
480
+ var WINDOW_BIND_FN = Symbol.for('PLANET_WINDOW_BIND_FN');
481
+ var DOCUMENT_BIND_FN = Symbol.for('PLANET_DOCUMENT_BIND_FN');
482
+
483
+ var rawHasOwnProperty = Object.prototype.hasOwnProperty;
484
+ function hasOwnProp(obj, key) {
485
+ return rawHasOwnProperty.call(obj, key);
486
+ }
487
+ function isValueDescriptor(desc) {
488
+ if (desc === undefined) {
489
+ return false;
490
+ }
491
+ return 'value' in desc || 'writable' in desc;
492
+ }
493
+ function isAccessorDescriptor(desc) {
494
+ if (desc === undefined) {
495
+ return false;
496
+ }
497
+ return 'get' in desc || 'set' in desc;
498
+ }
499
+ function isNonWriteableValue(desc) {
500
+ return desc && desc.configurable === false && 'value' in desc && desc.writable === false;
501
+ }
502
+ function isInvalidSetAccessor(desc) {
503
+ if (desc && desc.configurable === false && 'set' in desc && desc.set === undefined) {
504
+ return true;
505
+ }
506
+ else {
507
+ return false;
508
+ }
509
+ }
510
+ function isInvalidGetAccessor(desc) {
511
+ if (desc && desc.configurable === false && 'get' in desc && desc.get === undefined) {
512
+ return true;
513
+ }
514
+ else {
515
+ return false;
445
516
  }
446
- return privateMap.get(receiver);
447
517
  }
448
- function __classPrivateFieldSet(receiver, privateMap, value) {
449
- if (!privateMap.has(receiver)) {
450
- throw new TypeError("attempted to set private field on non-instance");
518
+ function transferParams(args) {
519
+ args = Array.isArray(args) ? args : Array.from(args);
520
+ return args.map(function (arg) {
521
+ return arg[RAW_NODE] ? arg[RAW_NODE] : arg;
522
+ });
523
+ }
524
+ var buildInProps = ['length', 'caller', 'callee', 'arguments', 'prototype', Symbol.hasInstance];
525
+ function transferProps(o, n) {
526
+ var e_1, _a;
527
+ try {
528
+ for (var _b = __values(Reflect.ownKeys(o)), _c = _b.next(); !_c.done; _c = _b.next()) {
529
+ var key = _c.value;
530
+ if (buildInProps.includes(key)) {
531
+ continue;
532
+ }
533
+ var desc = Object.getOwnPropertyDescriptor(n, key);
534
+ if (desc && desc.writable) {
535
+ n[key] = o[key];
536
+ }
537
+ }
538
+ }
539
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
540
+ finally {
541
+ try {
542
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
543
+ }
544
+ finally { if (e_1) throw e_1.error; }
545
+ }
546
+ }
547
+ function bind(fn, context) {
548
+ var fNOP = function () { };
549
+ function bound() {
550
+ var args = transferParams(arguments);
551
+ if (this instanceof bound) {
552
+ var obj = new (fn.bind.apply(fn, __spreadArray([void 0], __read(args))))();
553
+ Object.setPrototypeOf(obj, bound.prototype);
554
+ return obj;
555
+ }
556
+ else {
557
+ return fn.apply(context, args);
558
+ }
559
+ }
560
+ bound.$native = fn;
561
+ transferProps(fn, bound);
562
+ if (fn.prototype) {
563
+ fNOP.prototype = fn.prototype;
564
+ }
565
+ bound.prototype = new fNOP();
566
+ if (Symbol.hasInstance) {
567
+ Object.defineProperty(bound, Symbol.hasInstance, {
568
+ configurable: true,
569
+ value: function (instance) {
570
+ var op = fn.prototype;
571
+ return isObject(op) || typeof op === 'function' ? instance instanceof fn : false;
572
+ }
573
+ });
574
+ }
575
+ return bound;
576
+ }
577
+ function createFakeObject(target, writableKeys) {
578
+ var fakeObject = {};
579
+ var propertyMap = {};
580
+ var storageBox = Object.create(null);
581
+ var propertyNames = Object.getOwnPropertyNames(target);
582
+ var def = function (p) {
583
+ var descriptor = Object.getOwnPropertyDescriptor(target, p);
584
+ if (descriptor === null || descriptor === void 0 ? void 0 : descriptor.configurable) {
585
+ var hasGetter = hasOwnProp(descriptor, 'get');
586
+ var hasSetter = hasOwnProp(descriptor, 'set');
587
+ var canWritable = writableKeys && writableKeys.length > 0 && writableKeys.includes(p);
588
+ if (hasGetter) {
589
+ descriptor.get = function () { return (hasOwnProp(storageBox, p) ? storageBox[p] : target[p]); };
590
+ }
591
+ if (hasSetter) {
592
+ descriptor.set = function (val) {
593
+ storageBox[p] = val;
594
+ return true;
595
+ };
596
+ }
597
+ if (canWritable) {
598
+ if (descriptor.writable === false) {
599
+ descriptor.writable = true;
600
+ }
601
+ else if (hasGetter) {
602
+ descriptor.set = function (val) {
603
+ storageBox[p] = val;
604
+ return true;
605
+ };
606
+ }
607
+ }
608
+ Object.defineProperty(fakeObject, p, Object.freeze(descriptor));
609
+ }
610
+ };
611
+ propertyNames.forEach(function (p) {
612
+ propertyMap[p] = true;
613
+ def(p);
614
+ });
615
+ // 再次循环是为了处理原型链中的属性
616
+ for (var prop in target) {
617
+ if (!propertyMap[prop]) {
618
+ def(prop);
619
+ }
620
+ }
621
+ return fakeObject;
622
+ }
623
+
624
+ var esGlobalFunctions = ('eval,isFinite,isNaN,parseFloat,parseInt,' +
625
+ // URL handling functions
626
+ 'decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
627
+ // Constructor properties of the global object
628
+ 'Array,ArrayBuffer,BigInt,BigInt64Array,BigUint64Array,Boolean,DataView,Date,Error,EvalError,' +
629
+ 'FinalizationRegistry,Float32Array,Float64Array,Function,Int8Array,Int16Array,Int32Array,Map,Number,' +
630
+ 'Object,Promise,Proxy,RangeError,ReferenceError,RegExp,Set,SharedArrayBuffer,String,Symbol,SyntaxError,' +
631
+ 'TypeError,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,URIError,WeakMap,WeakRef,WeakSet,' +
632
+ // Other Properties of the Global Object
633
+ 'Atomics,JSON,Math,Reflect').split(',');
634
+ var whitelistVariables = PLANET_SANDBOX_WINDOW_WHITELIST || [];
635
+ function isConstructor(fn) {
636
+ var fp = fn.prototype;
637
+ var hasConstructor = fp && fp.constructor === fn && Object.getOwnPropertyNames(fp).length > 1;
638
+ var functionStr = !hasConstructor && fn.toString();
639
+ return hasConstructor || /^function\s+[A-Z]/.test(functionStr) || /^class\b/.test(functionStr);
640
+ }
641
+ var unscopables = {
642
+ undefined: true,
643
+ Array: true,
644
+ Object: true,
645
+ String: true,
646
+ Boolean: true,
647
+ Math: true,
648
+ Number: true,
649
+ Symbol: true,
650
+ parseFloat: true,
651
+ Float32Array: true
652
+ };
653
+ var ProxyWindow = /** @class */ (function () {
654
+ function ProxyWindow(sandbox) {
655
+ this.sandbox = sandbox;
656
+ this.definedVariables = new Set();
657
+ }
658
+ ProxyWindow.prototype.createGetter = function () {
659
+ var _this = this;
660
+ return function (target, key, receiver) {
661
+ if (key === Symbol.unscopables) {
662
+ return unscopables;
663
+ }
664
+ if (key === SANDBOX_INSTANCE) {
665
+ return _this.sandbox;
666
+ }
667
+ var value = null;
668
+ if (whitelistVariables.includes(key)) {
669
+ return Reflect.get(window, key);
670
+ }
671
+ else {
672
+ value = hasOwnProp(target, key) ? Reflect.get(target, key, receiver) : Reflect.get(window, key);
673
+ }
674
+ if (isFunction(value)) {
675
+ if (esGlobalFunctions.includes(key) ||
676
+ whitelistVariables.includes(key) ||
677
+ _this.sandbox.rewriteVariables.includes(key) ||
678
+ _this.definedVariables.has(key) ||
679
+ isConstructor(value)) {
680
+ return value;
681
+ }
682
+ else {
683
+ var newValue = hasOwnProp(value, WINDOW_BIND_FN) ? value[WINDOW_BIND_FN] : bind(value, window);
684
+ var desc = Object.getOwnPropertyDescriptor(target, key);
685
+ if (isNonWriteableValue(desc)) {
686
+ return value;
687
+ }
688
+ if (isInvalidGetAccessor(desc)) {
689
+ return undefined;
690
+ }
691
+ value[WINDOW_BIND_FN] = newValue;
692
+ return newValue;
693
+ }
694
+ }
695
+ else {
696
+ return value;
697
+ }
698
+ };
699
+ };
700
+ ProxyWindow.prototype.createSetter = function () {
701
+ var _this = this;
702
+ return function (target, key, value, receiver) {
703
+ var desc = Object.getOwnPropertyDescriptor(whitelistVariables.includes(key) ? window : receiver ? receiver : target, key);
704
+ if (desc && isNonWriteableValue(desc)) {
705
+ if (!Object.is(value, desc.value)) {
706
+ return false;
707
+ }
708
+ else {
709
+ return true;
710
+ }
711
+ }
712
+ if (isInvalidSetAccessor(desc)) {
713
+ return false;
714
+ }
715
+ if (whitelistVariables.includes(key)) {
716
+ return Reflect.set(window, key, value);
717
+ }
718
+ else {
719
+ var success = Reflect.set(target, key, value, receiver);
720
+ if (success) {
721
+ if (_this.sandbox.running) {
722
+ _this.definedVariables.add(key);
723
+ }
724
+ }
725
+ return success;
726
+ }
727
+ };
728
+ };
729
+ ProxyWindow.prototype.createDefineProperty = function () {
730
+ var _this = this;
731
+ return function (target, p, descriptor) {
732
+ if (whitelistVariables.includes(p)) {
733
+ return Reflect.defineProperty(window, p, descriptor);
734
+ }
735
+ else {
736
+ var success = Reflect.defineProperty(target, p, descriptor);
737
+ if (_this.sandbox.running && success) {
738
+ _this.definedVariables.add(p);
739
+ }
740
+ return success;
741
+ }
742
+ };
743
+ };
744
+ ProxyWindow.prototype.createDeleteProperty = function () {
745
+ var _this = this;
746
+ return function (target, p) {
747
+ if (hasOwnProp(target, p)) {
748
+ delete target[p];
749
+ if (_this.sandbox.running && _this.definedVariables.has(p)) {
750
+ _this.definedVariables.delete(p);
751
+ }
752
+ }
753
+ return true;
754
+ };
755
+ };
756
+ ProxyWindow.prototype.createHas = function () {
757
+ return function (_target, key) {
758
+ return !whitelistVariables.includes(key);
759
+ };
760
+ };
761
+ ProxyWindow.prototype.create = function () {
762
+ var fakeWindow = createFakeObject(window, this.sandbox.rewriteVariables);
763
+ var baseHandlers = {
764
+ get: this.createGetter(),
765
+ set: this.createSetter(),
766
+ defineProperty: this.createDefineProperty(),
767
+ deleteProperty: this.createDeleteProperty()
768
+ };
769
+ var proxy = new Proxy(fakeWindow, Object.assign(Object.assign({}, baseHandlers), { has: this.createHas() }));
770
+ var subProxy = new Proxy(fakeWindow, baseHandlers);
771
+ proxy.self = subProxy;
772
+ proxy.window = subProxy;
773
+ proxy.globalThis = subProxy;
774
+ proxy.top = window.top === window ? subProxy : window.top;
775
+ proxy.parent = window.parent === window ? subProxy : window.top;
776
+ return proxy;
777
+ };
778
+ return ProxyWindow;
779
+ }());
780
+
781
+ function eventListenerPatch(sandbox) {
782
+ var rawAddEventListener = window.addEventListener;
783
+ var rawRemoveEventListener = window.removeEventListener;
784
+ var listenerSubscriptions = new Map();
785
+ function addEventListener(type, listener, options) {
786
+ var _this = this;
787
+ var observable = new rxjs.Observable(function () {
788
+ rawAddEventListener.call(_this, type, listener, options);
789
+ return function () {
790
+ rawRemoveEventListener.call(_this, type, listener, options);
791
+ };
792
+ });
793
+ var subscription = observable.subscribe(function () { });
794
+ listenerSubscriptions.set(listener, subscription);
795
+ }
796
+ function removeEventListener(type, listener) {
797
+ var subscription = listenerSubscriptions.get(listener);
798
+ if (subscription) {
799
+ subscription.unsubscribe();
800
+ listenerSubscriptions.delete(listener);
801
+ }
451
802
  }
452
- privateMap.set(receiver, value);
453
- return value;
803
+ return {
804
+ rewrite: {
805
+ addEventListener: addEventListener.bind(window),
806
+ removeEventListener: removeEventListener.bind(window)
807
+ },
808
+ init: function () {
809
+ var fakeDocument = sandbox.global.document;
810
+ if (fakeDocument) {
811
+ fakeDocument.addEventListener = addEventListener.bind(document);
812
+ fakeDocument.removeEventListener = removeEventListener.bind(document);
813
+ }
814
+ },
815
+ destroy: function () {
816
+ listenerSubscriptions.forEach(function (subscription) { return subscription.unsubscribe(); });
817
+ listenerSubscriptions.clear();
818
+ }
819
+ };
820
+ }
821
+
822
+ var rawDocument = Document;
823
+ var whitelist = __spreadArray(['cookie', 'title', 'location'], __read((PLANET_SANDBOX_DOCUMENT_WHITELIST || [])));
824
+ var ProxyDocument = /** @class */ (function () {
825
+ function ProxyDocument() {
826
+ }
827
+ ProxyDocument.prototype.createGetter = function () {
828
+ return function (target, p, receiver) {
829
+ var value = hasOwnProp(target, p) ? Reflect.get(target, p, receiver) : Reflect.get(document, p);
830
+ if (p === 'activeElement') {
831
+ return Reflect.get(document, p);
832
+ }
833
+ // TODO: 处理动态节点
834
+ // if (p === 'createElement') {
835
+ // return function(tagName: string, options: ElementCreationOptions) {
836
+ // const created = value.call(document, tagName, options);
837
+ // if (isObject(created)) {
838
+ // created[SANDBOX_INSTANCE] = sandbox;
839
+ // }
840
+ // return created;
841
+ // };
842
+ // }
843
+ if (isFunction(value)) {
844
+ var newValue = hasOwnProp(value, DOCUMENT_BIND_FN) ? value[DOCUMENT_BIND_FN] : null;
845
+ if (!newValue) {
846
+ newValue = bind(value, document);
847
+ }
848
+ var desc = Object.getOwnPropertyDescriptor(target, p);
849
+ if (desc && isNonWriteableValue(desc)) {
850
+ if (!Object.is(newValue, desc.value)) {
851
+ return value;
852
+ }
853
+ }
854
+ if (isInvalidGetAccessor(desc)) {
855
+ return undefined;
856
+ }
857
+ value[DOCUMENT_BIND_FN] = newValue;
858
+ return newValue;
859
+ }
860
+ return value;
861
+ };
862
+ };
863
+ ProxyDocument.prototype.createSetter = function () {
864
+ return function (target, p, value, receiver) {
865
+ var desc = Object.getOwnPropertyDescriptor(whitelist.includes(p) ? document : receiver || target, p);
866
+ if (desc && isNonWriteableValue(desc)) {
867
+ if (Object.is(value, desc.value)) {
868
+ return true;
869
+ }
870
+ else {
871
+ return false;
872
+ }
873
+ }
874
+ if (isInvalidSetAccessor(desc)) {
875
+ return false;
876
+ }
877
+ return whitelist.includes(p) ? Reflect.set(document, p, value) : Reflect.set(target, p, value, receiver);
878
+ };
879
+ };
880
+ ProxyDocument.prototype.createDefineProperty = function () {
881
+ return function (target, p, descriptor) {
882
+ return whitelist.includes(p)
883
+ ? Reflect.defineProperty(document, p, descriptor)
884
+ : Reflect.defineProperty(target, p, descriptor);
885
+ };
886
+ };
887
+ ProxyDocument.prototype.create = function () {
888
+ var _a;
889
+ var proxyDocument = null;
890
+ var fakeDocument = createFakeObject(document);
891
+ var getter = this.createGetter();
892
+ var fakeDocumentProto = new Proxy(fakeDocument, {
893
+ get: function () {
894
+ var args = [];
895
+ for (var _i = 0; _i < arguments.length; _i++) {
896
+ args[_i] = arguments[_i];
897
+ }
898
+ return getter.apply(void 0, __spreadArray([], __read(args)));
899
+ }
900
+ });
901
+ var fakeDocumentCtor = function Document() {
902
+ if (!(this instanceof fakeDocumentCtor)) {
903
+ throw new TypeError("Failed to construct 'Document': Please use the 'new' operator.");
904
+ }
905
+ var docInstance = new rawDocument();
906
+ Object.setPrototypeOf(docInstance, fakeDocument);
907
+ return docInstance;
908
+ };
909
+ fakeDocumentCtor.prototype = fakeDocumentProto;
910
+ fakeDocumentCtor.prototype.constructor = fakeDocumentCtor;
911
+ if (Symbol.hasInstance) {
912
+ Object.defineProperty(fakeDocumentCtor, Symbol.hasInstance, {
913
+ configurable: true,
914
+ value: function (value) {
915
+ var proto = value;
916
+ if (proto === document) {
917
+ return true;
918
+ }
919
+ while ((proto = Object.getPrototypeOf(proto))) {
920
+ if (proto === fakeDocumentProto) {
921
+ return true;
922
+ }
923
+ }
924
+ var cloned = function () { };
925
+ cloned.prototype = fakeDocument;
926
+ return value instanceof cloned;
927
+ }
928
+ });
929
+ }
930
+ proxyDocument = new Proxy(Object.create(fakeDocumentProto, (_a = {
931
+ currentScript: {
932
+ value: null,
933
+ writable: true
934
+ }
935
+ },
936
+ _a[RAW_NODE] = {
937
+ writable: false,
938
+ configurable: false,
939
+ value: document
940
+ },
941
+ _a)), {
942
+ set: this.createSetter(),
943
+ defineProperty: this.createDefineProperty()
944
+ });
945
+ return {
946
+ document: proxyDocument,
947
+ Document: fakeDocumentCtor
948
+ };
949
+ };
950
+ return ProxyDocument;
951
+ }());
952
+
953
+ function documentPatch() {
954
+ var proxyDocument = new ProxyDocument();
955
+ var _a = proxyDocument.create(), document = _a.document, Document = _a.Document;
956
+ return {
957
+ rewrite: {
958
+ document: document,
959
+ Document: Document
960
+ }
961
+ };
962
+ }
963
+
964
+ var rawSetTimeout = window.setTimeout;
965
+ var rawClearTimeout = window.clearTimeout;
966
+ var rawSetInterval = window.setInterval;
967
+ var rawClearInterval = window.clearInterval;
968
+ function timerPatch() {
969
+ var timeout = new Set();
970
+ var interval = new Set();
971
+ function rewriteSetTimeout(handler, ms) {
972
+ var args = [];
973
+ for (var _i = 2; _i < arguments.length; _i++) {
974
+ args[_i - 2] = arguments[_i];
975
+ }
976
+ var timeoutId = rawSetTimeout.apply(void 0, __spreadArray([handler, ms], __read(args)));
977
+ timeout.add(timeoutId);
978
+ return timeoutId;
979
+ }
980
+ function rewriteClearTimeout(timeoutId) {
981
+ timeout.delete(timeoutId);
982
+ rawClearTimeout(timeoutId);
983
+ }
984
+ function rewriteSetInterval(handler, ms) {
985
+ var args = [];
986
+ for (var _i = 2; _i < arguments.length; _i++) {
987
+ args[_i - 2] = arguments[_i];
988
+ }
989
+ var intervalId = rawSetInterval.apply(void 0, __spreadArray([handler, ms], __read(args)));
990
+ interval.add(intervalId);
991
+ return intervalId;
992
+ }
993
+ function rewriteClearInterval(intervalId) {
994
+ interval.delete(intervalId);
995
+ rawClearInterval(intervalId);
996
+ }
997
+ return {
998
+ rewrite: {
999
+ setTimeout: rewriteSetTimeout,
1000
+ clearTimeout: rewriteClearTimeout,
1001
+ setInterval: rewriteSetInterval,
1002
+ clearInterval: rewriteClearInterval
1003
+ },
1004
+ destroy: function () {
1005
+ timeout.forEach(function (timeoutId) {
1006
+ rawClearTimeout(timeoutId);
1007
+ });
1008
+ interval.forEach(function (intervalId) {
1009
+ rawClearInterval(intervalId);
1010
+ });
1011
+ }
1012
+ };
1013
+ }
1014
+
1015
+ var PLANET_STORAGE_PREFIX = '__planet-storage-';
1016
+ var RewriteStorage = /** @class */ (function () {
1017
+ function RewriteStorage(app, rawStorage) {
1018
+ this.rawStorage = rawStorage;
1019
+ this.prefix = "" + PLANET_STORAGE_PREFIX + app + "__:";
1020
+ }
1021
+ Object.defineProperty(RewriteStorage.prototype, "length", {
1022
+ get: function () {
1023
+ return this.getKeys().length;
1024
+ },
1025
+ enumerable: false,
1026
+ configurable: true
1027
+ });
1028
+ RewriteStorage.prototype.getKeys = function () {
1029
+ var _this = this;
1030
+ return Object.keys(this.rawStorage).filter(function (key) { return key.startsWith(_this.prefix); });
1031
+ };
1032
+ RewriteStorage.prototype.key = function (n) {
1033
+ var key = this.getKeys()[n];
1034
+ return key ? key.substring(this.prefix.length) : null;
1035
+ };
1036
+ RewriteStorage.prototype.getItem = function (key) {
1037
+ return this.rawStorage.getItem("" + (this.prefix + key));
1038
+ };
1039
+ RewriteStorage.prototype.setItem = function (key, value) {
1040
+ this.rawStorage.setItem("" + (this.prefix + key), value);
1041
+ };
1042
+ RewriteStorage.prototype.removeItem = function (key) {
1043
+ this.rawStorage.removeItem("" + (this.prefix + key));
1044
+ };
1045
+ RewriteStorage.prototype.clear = function () {
1046
+ var _this = this;
1047
+ this.getKeys().forEach(function (key) {
1048
+ _this.rawStorage.removeItem(key);
1049
+ });
1050
+ };
1051
+ return RewriteStorage;
1052
+ }());
1053
+ function storagePatch(sandbox) {
1054
+ return {
1055
+ rewrite: {
1056
+ localStorage: new RewriteStorage(sandbox.app, localStorage),
1057
+ sessionStorage: new RewriteStorage(sandbox.app, sessionStorage)
1058
+ }
1059
+ };
1060
+ }
1061
+
1062
+ var sandboxPatches = [documentPatch, eventListenerPatch, timerPatch, storagePatch];
1063
+ function getSandboxPatchHandlers(sandbox) {
1064
+ return sandboxPatches.map(function (patch) {
1065
+ return patch(sandbox);
1066
+ });
1067
+ }
1068
+
1069
+ function execScript(code, url, global, strictGlobal) {
1070
+ var sourceUrl = '//# sourceURL='.concat(url, '\n');
1071
+ var window = (0, eval)('window');
1072
+ window.tempGlobal = global;
1073
+ code = strictGlobal
1074
+ ? ';(function(window, self, globalThis){with(window){;'
1075
+ .concat(code, '\n')
1076
+ .concat(sourceUrl, '}}).bind(window.tempGlobal)(window.tempGlobal, window.tempGlobal, window.tempGlobal);')
1077
+ : ';(function(window, self, globalThis){;'
1078
+ .concat(code, '\n')
1079
+ .concat(sourceUrl, '}).bind(window.tempGlobal)(window.tempGlobal, window.tempGlobal, window.tempGlobal);');
1080
+ (0, eval)(code);
1081
+ delete window.tempGlobal;
1082
+ }
1083
+
1084
+ var Sandbox = /** @class */ (function () {
1085
+ function Sandbox() {
1086
+ }
1087
+ Sandbox.prototype.execScript = function (code, url) {
1088
+ if (url === void 0) { url = ''; }
1089
+ execScript(code, url, this.global, !!this.options.strictGlobal);
1090
+ };
1091
+ return Sandbox;
1092
+ }());
1093
+
1094
+ var ProxySandbox = /** @class */ (function (_super) {
1095
+ __extends(ProxySandbox, _super);
1096
+ function ProxySandbox(app, options) {
1097
+ var _this = _super.call(this) || this;
1098
+ _this.app = app;
1099
+ _this.options = options;
1100
+ _this.running = false;
1101
+ _this.patchHandlers = [];
1102
+ _this.patchHandlers = getSandboxPatchHandlers(_this);
1103
+ _this.start();
1104
+ return _this;
1105
+ }
1106
+ ProxySandbox.prototype.start = function () {
1107
+ this.running = true;
1108
+ this.rewriteVariables = this.getPatchRewriteVariables();
1109
+ var proxyWindow = new ProxyWindow(this);
1110
+ this.global = proxyWindow.create();
1111
+ this.execPatchHandlers();
1112
+ };
1113
+ ProxySandbox.prototype.destroy = function () {
1114
+ this.running = false;
1115
+ this.patchHandlers.forEach(function (handler) {
1116
+ if (handler.destroy) {
1117
+ handler.destroy();
1118
+ }
1119
+ });
1120
+ };
1121
+ ProxySandbox.prototype.getPatchRewriteVariables = function () {
1122
+ return this.patchHandlers.reduce(function (pre, cur) {
1123
+ return __spreadArray(__spreadArray([], __read(pre)), __read((cur.rewrite ? Object.keys(cur.rewrite) : [])));
1124
+ }, []);
1125
+ };
1126
+ ProxySandbox.prototype.execPatchHandlers = function () {
1127
+ var _this = this;
1128
+ this.patchHandlers.forEach(function (handler) {
1129
+ if (handler.rewrite) {
1130
+ for (var key in handler.rewrite) {
1131
+ if (handler.rewrite[key]) {
1132
+ _this.global[key] = handler.rewrite[key];
1133
+ }
1134
+ }
1135
+ }
1136
+ if (handler.init) {
1137
+ handler === null || handler === void 0 ? void 0 : handler.init();
1138
+ }
1139
+ });
1140
+ };
1141
+ return ProxySandbox;
1142
+ }(Sandbox));
1143
+
1144
+ var SnapshotSandbox = /** @class */ (function (_super) {
1145
+ __extends(SnapshotSandbox, _super);
1146
+ function SnapshotSandbox(app, options) {
1147
+ var _this = _super.call(this) || this;
1148
+ _this.app = app;
1149
+ _this.options = options;
1150
+ _this.start();
1151
+ return _this;
1152
+ }
1153
+ SnapshotSandbox.prototype.start = function () { };
1154
+ SnapshotSandbox.prototype.destroy = function () { };
1155
+ return SnapshotSandbox;
1156
+ }(Sandbox));
1157
+
1158
+ var defaultOptions = {
1159
+ strictGlobal: false
1160
+ };
1161
+ function createSandbox(app, options) {
1162
+ options = Object.assign({}, defaultOptions, options || {});
1163
+ if (window.Proxy) {
1164
+ return new ProxySandbox(app, options);
1165
+ }
1166
+ else {
1167
+ return new SnapshotSandbox(app, options);
1168
+ }
1169
+ }
1170
+ function getSandboxInstance() {
1171
+ return window[SANDBOX_INSTANCE];
454
1172
  }
455
1173
 
456
1174
  var AssetsLoader = /** @class */ (function () {
@@ -516,6 +1234,41 @@
516
1234
  document.body.appendChild(script);
517
1235
  });
518
1236
  };
1237
+ AssetsLoader.prototype.loadScriptWithSandbox = function (app, src) {
1238
+ var _this = this;
1239
+ var id = hashCode(src);
1240
+ if (this.loadedSources.includes(id)) {
1241
+ return rxjs.of({
1242
+ src: src,
1243
+ hashCode: id,
1244
+ loaded: true,
1245
+ status: 'Loaded'
1246
+ });
1247
+ }
1248
+ return new rxjs.Observable(function (observer) {
1249
+ _this.http.get(src, { responseType: 'text' }).subscribe(function (code) {
1250
+ _this.loadedSources.push(id);
1251
+ var sandbox = createSandbox(app);
1252
+ sandbox.execScript(code, src);
1253
+ observer.next({
1254
+ src: src,
1255
+ hashCode: id,
1256
+ loaded: true,
1257
+ status: 'Loaded'
1258
+ });
1259
+ observer.complete();
1260
+ }, function (error) {
1261
+ observer.error({
1262
+ src: src,
1263
+ hashCode: id,
1264
+ loaded: false,
1265
+ status: 'Error',
1266
+ error: error
1267
+ });
1268
+ observer.complete();
1269
+ });
1270
+ });
1271
+ };
519
1272
  AssetsLoader.prototype.loadStyle = function (src) {
520
1273
  var _this = this;
521
1274
  var id = hashCode(src);
@@ -557,17 +1310,26 @@
557
1310
  head.appendChild(link);
558
1311
  });
559
1312
  };
560
- AssetsLoader.prototype.loadScripts = function (sources, serial) {
1313
+ AssetsLoader.prototype.loadScripts = function (sources, options) {
561
1314
  var _this = this;
562
- if (serial === void 0) { serial = false; }
1315
+ if (options === void 0) { options = {
1316
+ serial: false,
1317
+ sandbox: false
1318
+ }; }
563
1319
  if (isEmpty(sources)) {
564
1320
  return rxjs.of(null);
565
1321
  }
566
1322
  var observables = sources.map(function (src) {
567
- return _this.loadScript(src);
1323
+ // TODO: 暂时只支持Proxy沙箱
1324
+ if (options.sandbox && window.Proxy) {
1325
+ return _this.loadScriptWithSandbox(options.app, src);
1326
+ }
1327
+ else {
1328
+ return _this.loadScript(src);
1329
+ }
568
1330
  });
569
- if (serial) {
570
- var a = rxjs.concat.apply(void 0, __spread(observables)).pipe(operators.map(function (item) {
1331
+ if (options.serial) {
1332
+ var a = rxjs.concat.apply(void 0, __spreadArray([], __read(observables))).pipe(operators.map(function (item) {
571
1333
  return rxjs.of([item]);
572
1334
  }), operators.concatAll());
573
1335
  return a;
@@ -585,23 +1347,30 @@
585
1347
  return _this.loadStyle(src);
586
1348
  }));
587
1349
  };
588
- AssetsLoader.prototype.loadScriptsAndStyles = function (scripts, styles, serial) {
1350
+ AssetsLoader.prototype.loadScriptsAndStyles = function (scripts, styles, options) {
589
1351
  if (scripts === void 0) { scripts = []; }
590
1352
  if (styles === void 0) { styles = []; }
591
- if (serial === void 0) { serial = false; }
592
- return rxjs.forkJoin([this.loadScripts(scripts, serial), this.loadStyles(styles)]);
1353
+ return rxjs.forkJoin([this.loadScripts(scripts, options), this.loadStyles(styles)]);
593
1354
  };
594
1355
  AssetsLoader.prototype.loadAppAssets = function (app) {
595
1356
  var _this = this;
596
1357
  if (app.manifest) {
597
1358
  return this.loadManifest(app.manifest + "?t=" + new Date().getTime()).pipe(operators.switchMap(function (manifestResult) {
598
1359
  var _a = getScriptsAndStylesFullPaths(app, manifestResult), scripts = _a.scripts, styles = _a.styles;
599
- return _this.loadScriptsAndStyles(scripts, styles, app.loadSerial);
1360
+ return _this.loadScriptsAndStyles(scripts, styles, {
1361
+ app: app.name,
1362
+ sandbox: app.sandbox,
1363
+ serial: app.loadSerial
1364
+ });
600
1365
  }));
601
1366
  }
602
1367
  else {
603
1368
  var _a = getScriptsAndStylesFullPaths(app), scripts = _a.scripts, styles = _a.styles;
604
- return this.loadScriptsAndStyles(scripts, styles, app.loadSerial);
1369
+ return this.loadScriptsAndStyles(scripts, styles, {
1370
+ app: app.name,
1371
+ sandbox: app.sandbox,
1372
+ serial: app.loadSerial
1373
+ });
605
1374
  }
606
1375
  };
607
1376
  AssetsLoader.prototype.loadManifest = function (url) {
@@ -626,15 +1395,15 @@
626
1395
  this.name = name;
627
1396
  if (options) {
628
1397
  this.template = options.template;
629
- this.innerSelector = this.template ? getTagNameByTemplate(this.template) : null;
1398
+ this.innerSelector = this.template ? getTagNameByTemplate(this.template) : '';
630
1399
  this.appModuleBootstrap = options.bootstrap;
631
1400
  }
632
1401
  // This is a hack, since NgZone doesn't allow you to configure the property that identifies your zone.
633
1402
  // See https://github.com/PlaceMe-SAS/single-spa-angular-cli/issues/33,
634
- // NgZone.isInAngularZone = () => {
635
- // // @ts-ignore
636
- // return window.Zone.current._properties[`ngx-planet-${name}`] === true;
637
- // };
1403
+ i0.NgZone.isInAngularZone = function () {
1404
+ // @ts-ignore
1405
+ return window.Zone.current._properties["ngx-planet-" + name] === true;
1406
+ };
638
1407
  }
639
1408
  Object.defineProperty(PlanetApplicationRef.prototype, "selector", {
640
1409
  get: function () {
@@ -650,18 +1419,31 @@
650
1419
  enumerable: false,
651
1420
  configurable: true
652
1421
  });
1422
+ Object.defineProperty(PlanetApplicationRef.prototype, "ngZone", {
1423
+ get: function () {
1424
+ var _a;
1425
+ return (_a = this.appModuleRef) === null || _a === void 0 ? void 0 : _a.injector.get(i0.NgZone);
1426
+ },
1427
+ enumerable: false,
1428
+ configurable: true
1429
+ });
1430
+ Object.defineProperty(PlanetApplicationRef.prototype, "sandbox", {
1431
+ get: function () {
1432
+ return getSandboxInstance();
1433
+ },
1434
+ enumerable: false,
1435
+ configurable: true
1436
+ });
653
1437
  // 子应用路由变化后同步修改 portal 的 Route
654
1438
  PlanetApplicationRef.prototype.syncPortalRouteWhenNavigationEnd = function () {
655
1439
  var _this = this;
656
- var router = this.appModuleRef.injector.get(i3.Router);
657
- var ngZone = this.appModuleRef.injector.get(i0.NgZone);
1440
+ var _a;
1441
+ var router = (_a = this.appModuleRef) === null || _a === void 0 ? void 0 : _a.injector.get(i3.Router);
658
1442
  if (router) {
659
1443
  router.events.subscribe(function (event) {
1444
+ var _a;
660
1445
  if (event instanceof i3.NavigationEnd) {
661
- ngZone.onStable
662
- .asObservable()
663
- .pipe(operators.take(1))
664
- .subscribe(function () {
1446
+ (_a = _this.ngZone) === null || _a === void 0 ? void 0 : _a.onStable.asObservable().pipe(operators.take(1)).subscribe(function () {
665
1447
  _this.portalApp.router.navigateByUrl(event.url);
666
1448
  });
667
1449
  }
@@ -682,16 +1464,18 @@
682
1464
  }));
683
1465
  };
684
1466
  PlanetApplicationRef.prototype.getRouter = function () {
685
- return this.appModuleRef.injector.get(i3.Router);
1467
+ var _a;
1468
+ return (_a = this.appModuleRef) === null || _a === void 0 ? void 0 : _a.injector.get(i3.Router);
686
1469
  };
687
1470
  PlanetApplicationRef.prototype.getCurrentRouterStateUrl = function () {
688
- return this.getRouter().routerState.snapshot.url;
1471
+ var _a;
1472
+ return (_a = this.getRouter()) === null || _a === void 0 ? void 0 : _a.routerState.snapshot.url;
689
1473
  };
690
1474
  PlanetApplicationRef.prototype.navigateByUrl = function (url) {
691
- var ngZone = this.appModuleRef.injector.get(i0.NgZone);
1475
+ var _a;
692
1476
  var router = this.getRouter();
693
- ngZone.run(function () {
694
- router.navigateByUrl(url);
1477
+ (_a = this.ngZone) === null || _a === void 0 ? void 0 : _a.run(function () {
1478
+ router === null || router === void 0 ? void 0 : router.navigateByUrl(url);
695
1479
  });
696
1480
  };
697
1481
  PlanetApplicationRef.prototype.getComponentFactory = function () {
@@ -706,8 +1490,11 @@
706
1490
  if (router) {
707
1491
  router.dispose();
708
1492
  }
1493
+ if (this.sandbox) {
1494
+ this.sandbox.destroy();
1495
+ }
709
1496
  this.appModuleRef.destroy();
710
- delete this.appModuleRef;
1497
+ this.appModuleRef = undefined;
711
1498
  }
712
1499
  };
713
1500
  return PlanetApplicationRef;
@@ -738,10 +1525,13 @@
738
1525
  }
739
1526
  }
740
1527
  function setPortalApplicationData(data) {
741
- globalPlanet.portalApplication.data = data;
1528
+ if (globalPlanet.portalApplication) {
1529
+ globalPlanet.portalApplication.data = data;
1530
+ }
742
1531
  }
743
1532
  function getPortalApplicationData() {
744
- return globalPlanet.portalApplication.data;
1533
+ var _a;
1534
+ return (_a = globalPlanet.portalApplication) === null || _a === void 0 ? void 0 : _a.data;
745
1535
  }
746
1536
  function setApplicationLoader(loader) {
747
1537
  globalPlanet.applicationLoader = loader;
@@ -962,7 +1752,7 @@
962
1752
  _debugFactory = debug;
963
1753
  }
964
1754
  function clearDebugFactory() {
965
- setDebugFactory(undefined);
1755
+ _debugFactory = undefined;
966
1756
  _debuggerMap = {};
967
1757
  }
968
1758
  function getDebugFactory() {
@@ -1128,7 +1918,7 @@
1128
1918
  debug("[routeChange] app(" + app.name + ") status is bootstrapped, show app and active");
1129
1919
  _this.showApp(app);
1130
1920
  var appRef = getPlanetApplicationRef(app.name);
1131
- appRef.navigateByUrl(event.url);
1921
+ appRef === null || appRef === void 0 ? void 0 : appRef.navigateByUrl(event.url);
1132
1922
  _this.setAppStatus(app, exports.ApplicationStatus.active);
1133
1923
  _this.setLoadingDone();
1134
1924
  return rxjs.of(app);
@@ -1146,11 +1936,11 @@
1146
1936
  debug("[routeChange] app(" + app.name + ") is active, do nothings");
1147
1937
  var appRef = getPlanetApplicationRef(app.name);
1148
1938
  // Backwards compatibility sub app use old version which has not getCurrentRouterStateUrl
1149
- var currentUrl = appRef.getCurrentRouterStateUrl
1939
+ var currentUrl = (appRef === null || appRef === void 0 ? void 0 : appRef.getCurrentRouterStateUrl)
1150
1940
  ? appRef.getCurrentRouterStateUrl()
1151
1941
  : '';
1152
1942
  if (currentUrl !== event.url) {
1153
- appRef.navigateByUrl(event.url);
1943
+ appRef === null || appRef === void 0 ? void 0 : appRef.navigateByUrl(event.url);
1154
1944
  }
1155
1945
  return rxjs.of(app);
1156
1946
  }
@@ -1222,14 +2012,14 @@
1222
2012
  };
1223
2013
  PlanetApplicationLoader.prototype.hideApp = function (planetApp) {
1224
2014
  var appRef = getPlanetApplicationRef(planetApp.name);
1225
- var appRootElement = document.querySelector(appRef.selector || planetApp.selector);
2015
+ var appRootElement = document.querySelector((appRef === null || appRef === void 0 ? void 0 : appRef.selector) || planetApp.selector);
1226
2016
  if (appRootElement) {
1227
2017
  appRootElement.setAttribute('style', 'display:none;');
1228
2018
  }
1229
2019
  };
1230
2020
  PlanetApplicationLoader.prototype.showApp = function (planetApp) {
1231
2021
  var appRef = getPlanetApplicationRef(planetApp.name);
1232
- var appRootElement = document.querySelector(appRef.selector || planetApp.selector);
2022
+ var appRootElement = document.querySelector((appRef === null || appRef === void 0 ? void 0 : appRef.selector) || planetApp.selector);
1233
2023
  if (appRootElement) {
1234
2024
  appRootElement.setAttribute('style', '');
1235
2025
  }
@@ -1240,9 +2030,9 @@
1240
2030
  appRef.destroy();
1241
2031
  }
1242
2032
  var container = getHTMLElement(planetApp.hostParent);
1243
- var appRootElement = container.querySelector((appRef && appRef.selector) || planetApp.selector);
2033
+ var appRootElement = container === null || container === void 0 ? void 0 : container.querySelector((appRef && appRef.selector) || planetApp.selector);
1244
2034
  if (appRootElement) {
1245
- container.removeChild(appRootElement);
2035
+ container === null || container === void 0 ? void 0 : container.removeChild(appRootElement);
1246
2036
  }
1247
2037
  };
1248
2038
  PlanetApplicationLoader.prototype.bootstrapApp = function (app, defaultStatus) {
@@ -1266,10 +2056,10 @@
1266
2056
  }
1267
2057
  appRootElement_1.setAttribute('style', 'display:none;');
1268
2058
  if (app.hostClass) {
1269
- (_a = appRootElement_1.classList).add.apply(_a, __spread(coerceArray(app.hostClass)));
2059
+ (_a = appRootElement_1.classList).add.apply(_a, __spreadArray([], __read(coerceArray(app.hostClass))));
1270
2060
  }
1271
2061
  if (app.stylePrefix) {
1272
- (_b = appRootElement_1.classList).add.apply(_b, __spread(coerceArray(app.stylePrefix)));
2062
+ (_b = appRootElement_1.classList).add.apply(_b, __spreadArray([], __read(coerceArray(app.stylePrefix))));
1273
2063
  }
1274
2064
  container.appendChild(appRootElement_1);
1275
2065
  }
@@ -1341,13 +2131,15 @@
1341
2131
  PlanetApplicationLoader.prototype.preloadApps = function (activeApps) {
1342
2132
  var _this = this;
1343
2133
  setTimeout(function () {
1344
- var toPreloadApps = _this.planetApplicationService.getAppsToPreload(activeApps ? activeApps.map(function (item) { return item.name; }) : null);
2134
+ var toPreloadApps = _this.planetApplicationService.getAppsToPreload(activeApps ? activeApps.map(function (item) { return item.name; }) : undefined);
1345
2135
  debug("start preload apps: " + _this.getAppNames(toPreloadApps));
1346
2136
  var loadApps$ = toPreloadApps.map(function (preloadApp) {
1347
2137
  return _this.preloadInternal(preloadApp);
1348
2138
  });
1349
2139
  rxjs.forkJoin(loadApps$).subscribe({
1350
- error: function (error) { return _this.errorHandler(error); }
2140
+ error: function (error) {
2141
+ _this.errorHandler(error);
2142
+ }
1351
2143
  });
1352
2144
  });
1353
2145
  };
@@ -1383,6 +2175,9 @@
1383
2175
  return _this.bootstrapApp(app, 'hidden');
1384
2176
  });
1385
2177
  }
2178
+ }), operators.catchError(function (error) {
2179
+ _this.errorHandler(error);
2180
+ return rxjs.of(null);
1386
2181
  }), operators.map(function () {
1387
2182
  return getPlanetApplicationRef(app.name);
1388
2183
  }));
@@ -1511,7 +2306,8 @@
1511
2306
  });
1512
2307
  };
1513
2308
  Planet.prototype.stop = function () {
1514
- this.subscription.unsubscribe();
2309
+ var _a;
2310
+ (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
1515
2311
  };
1516
2312
  return Planet;
1517
2313
  }());
@@ -1693,10 +2489,9 @@
1693
2489
  });
1694
2490
  };
1695
2491
  PlanetComponentLoader.prototype.load = function (app, componentName, config) {
1696
- var _this = this;
1697
2492
  var result = this.getPlantAppRef(app).pipe(operators.delayWhen(function (appRef) {
1698
2493
  if (appRef.getComponentFactory()) {
1699
- return rxjs.of();
2494
+ return rxjs.of('');
1700
2495
  }
1701
2496
  else {
1702
2497
  // Because register use 'setTimeout',so timer 20
@@ -1710,8 +2505,6 @@
1710
2505
  else {
1711
2506
  throw new Error(app + "'s component(" + componentName + ") is not registered");
1712
2507
  }
1713
- }), operators.finalize(function () {
1714
- _this.applicationRef.tick();
1715
2508
  }), operators.shareReplay());
1716
2509
  result.subscribe();
1717
2510
  return result;