@worktile/planet 14.0.0 → 14.1.0
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/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/component/planet-component-loader.d.ts +5 -5
- package/component/planet-component-loader.d.ts.map +1 -1
- package/component/planet-component-outlet.d.ts +24 -0
- package/component/planet-component-outlet.d.ts.map +1 -0
- package/component/planet-component-ref.d.ts +1 -0
- package/component/planet-component-ref.d.ts.map +1 -1
- package/component/plant-component.config.d.ts +9 -2
- package/component/plant-component.config.d.ts.map +1 -1
- package/esm2020/component/planet-component-loader.mjs +39 -31
- package/esm2020/component/planet-component-outlet.mjs +68 -0
- package/esm2020/component/planet-component-ref.mjs +1 -1
- package/esm2020/component/plant-component.config.mjs +1 -1
- package/esm2020/module.mjs +5 -4
- package/esm2020/public-api.mjs +2 -1
- package/fesm2015/worktile-planet.mjs +129 -58
- package/fesm2015/worktile-planet.mjs.map +1 -1
- package/fesm2020/worktile-planet.mjs +128 -58
- package/fesm2020/worktile-planet.mjs.map +1 -1
- package/module.d.ts +3 -2
- package/module.d.ts.map +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/public-api.d.ts.map +1 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, NgZone, Injectable, Inject, Optional, Component, NgModule } from '@angular/core';
|
|
2
|
+
import { InjectionToken, NgZone, Injectable, Inject, Optional, Component, Injector, EventEmitter, Directive, Input, Output, NgModule } from '@angular/core';
|
|
3
3
|
import * as i3 from '@angular/router';
|
|
4
4
|
import { Router, NavigationEnd } from '@angular/router';
|
|
5
|
-
import { take, map, concatAll, switchMap, shareReplay, filter, distinctUntilChanged, catchError, tap, share, startWith, delayWhen } from 'rxjs/operators';
|
|
5
|
+
import { take, map, concatAll, switchMap, shareReplay, filter, distinctUntilChanged, catchError, tap, share, startWith, delayWhen, takeUntil } from 'rxjs/operators';
|
|
6
6
|
import { Observable, from, of, concat, forkJoin, Subject, timer } from 'rxjs';
|
|
7
7
|
import * as i1 from '@angular/common/http';
|
|
8
8
|
import { HttpClientModule } from '@angular/common/http';
|
|
9
|
-
import { PortalInjector, DomPortalOutlet, ComponentPortal } from '@angular/cdk/portal';
|
|
10
9
|
import { DOCUMENT } from '@angular/common';
|
|
11
10
|
|
|
12
11
|
var SwitchModes;
|
|
@@ -1855,32 +1854,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
|
|
|
1855
1854
|
}]
|
|
1856
1855
|
}] });
|
|
1857
1856
|
|
|
1858
|
-
class NgxPlanetModule {
|
|
1859
|
-
static forRoot(apps) {
|
|
1860
|
-
return {
|
|
1861
|
-
ngModule: NgxPlanetModule,
|
|
1862
|
-
providers: [
|
|
1863
|
-
{
|
|
1864
|
-
provide: PLANET_APPLICATIONS,
|
|
1865
|
-
useValue: apps
|
|
1866
|
-
}
|
|
1867
|
-
]
|
|
1868
|
-
};
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
NgxPlanetModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1872
|
-
NgxPlanetModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, declarations: [EmptyComponent], imports: [HttpClientModule], exports: [HttpClientModule, EmptyComponent] });
|
|
1873
|
-
NgxPlanetModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, imports: [HttpClientModule, HttpClientModule] });
|
|
1874
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, decorators: [{
|
|
1875
|
-
type: NgModule,
|
|
1876
|
-
args: [{
|
|
1877
|
-
declarations: [EmptyComponent],
|
|
1878
|
-
imports: [HttpClientModule],
|
|
1879
|
-
providers: [],
|
|
1880
|
-
exports: [HttpClientModule, EmptyComponent]
|
|
1881
|
-
}]
|
|
1882
|
-
}] });
|
|
1883
|
-
|
|
1884
1857
|
class PlanetComponentRef {
|
|
1885
1858
|
}
|
|
1886
1859
|
|
|
@@ -1891,7 +1864,6 @@ class PlanetComponentLoader {
|
|
|
1891
1864
|
this.ngModuleRef = ngModuleRef;
|
|
1892
1865
|
this.ngZone = ngZone;
|
|
1893
1866
|
this.document = document;
|
|
1894
|
-
this.domPortalOutletCache = new WeakMap();
|
|
1895
1867
|
}
|
|
1896
1868
|
get applicationLoader() {
|
|
1897
1869
|
return getApplicationLoader();
|
|
@@ -1911,9 +1883,15 @@ class PlanetComponentLoader {
|
|
|
1911
1883
|
}
|
|
1912
1884
|
}
|
|
1913
1885
|
createInjector(appModuleRef, componentRef) {
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1886
|
+
return Injector.create({
|
|
1887
|
+
providers: [
|
|
1888
|
+
{
|
|
1889
|
+
provide: PlanetComponentRef,
|
|
1890
|
+
useValue: componentRef
|
|
1891
|
+
}
|
|
1892
|
+
],
|
|
1893
|
+
parent: appModuleRef.injector
|
|
1894
|
+
});
|
|
1917
1895
|
}
|
|
1918
1896
|
getContainerElement(config) {
|
|
1919
1897
|
if (!config.container) {
|
|
@@ -1928,49 +1906,53 @@ class PlanetComponentLoader {
|
|
|
1928
1906
|
}
|
|
1929
1907
|
}
|
|
1930
1908
|
}
|
|
1931
|
-
|
|
1932
|
-
const container = this.getContainerElement(config);
|
|
1933
|
-
const element = this.document.createElement('div');
|
|
1909
|
+
insertComponentRootNodeToContainer(container, componentRootNode, hostClass) {
|
|
1934
1910
|
const subApp = this.applicationService.getAppByName(this.ngModuleRef.instance.appName);
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
if (
|
|
1938
|
-
|
|
1911
|
+
componentRootNode.classList.add(componentWrapperClass);
|
|
1912
|
+
componentRootNode.setAttribute('planet-inline', '');
|
|
1913
|
+
if (hostClass) {
|
|
1914
|
+
componentRootNode.classList.add(hostClass);
|
|
1939
1915
|
}
|
|
1940
1916
|
if (subApp && subApp.stylePrefix) {
|
|
1941
|
-
|
|
1917
|
+
componentRootNode.classList.add(subApp.stylePrefix);
|
|
1918
|
+
}
|
|
1919
|
+
// container 是注释则在前方插入,否则在元素内部插入
|
|
1920
|
+
if (container.nodeType === 8) {
|
|
1921
|
+
container.parentElement.insertBefore(componentRootNode, container);
|
|
1922
|
+
}
|
|
1923
|
+
else {
|
|
1924
|
+
container.appendChild(componentRootNode);
|
|
1942
1925
|
}
|
|
1943
|
-
container.appendChild(element);
|
|
1944
|
-
return element;
|
|
1945
1926
|
}
|
|
1946
1927
|
attachComponent(plantComponent, appModuleRef, config) {
|
|
1947
1928
|
const plantComponentRef = new PlanetComponentRef();
|
|
1948
1929
|
const componentFactoryResolver = appModuleRef.componentFactoryResolver;
|
|
1949
1930
|
const appRef = this.applicationRef;
|
|
1950
1931
|
const injector = this.createInjector(appModuleRef, plantComponentRef);
|
|
1951
|
-
const
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
portalOutlet = new DomPortalOutlet(wrapper, componentFactoryResolver, appRef, injector);
|
|
1958
|
-
this.domPortalOutletCache.set(wrapper, portalOutlet);
|
|
1959
|
-
}
|
|
1960
|
-
const componentPortal = new ComponentPortal(plantComponent.component, null);
|
|
1961
|
-
const componentRef = portalOutlet.attachComponentPortal(componentPortal);
|
|
1932
|
+
const container = this.getContainerElement(config);
|
|
1933
|
+
const componentFactory = componentFactoryResolver.resolveComponentFactory(plantComponent.component);
|
|
1934
|
+
const componentRef = componentFactory.create(injector);
|
|
1935
|
+
appRef.attachView(componentRef.hostView);
|
|
1936
|
+
const componentRootNode = this.getComponentRootNode(componentRef);
|
|
1937
|
+
this.insertComponentRootNodeToContainer(container, componentRootNode, config.hostClass || config.wrapperClass);
|
|
1962
1938
|
if (config.initialState) {
|
|
1963
1939
|
Object.assign(componentRef.instance, config.initialState);
|
|
1964
1940
|
}
|
|
1965
1941
|
plantComponentRef.componentInstance = componentRef.instance;
|
|
1966
1942
|
plantComponentRef.componentRef = componentRef;
|
|
1967
|
-
plantComponentRef.
|
|
1943
|
+
plantComponentRef.hostElement = componentRootNode;
|
|
1968
1944
|
plantComponentRef.dispose = () => {
|
|
1969
|
-
|
|
1970
|
-
|
|
1945
|
+
if (appRef.viewCount > 0) {
|
|
1946
|
+
appRef.detachView(componentRef.hostView);
|
|
1947
|
+
}
|
|
1948
|
+
componentRootNode.remove();
|
|
1971
1949
|
};
|
|
1972
1950
|
return plantComponentRef;
|
|
1973
1951
|
}
|
|
1952
|
+
/** Gets the root HTMLElement for an instantiated component. */
|
|
1953
|
+
getComponentRootNode(componentRef) {
|
|
1954
|
+
return componentRef.hostView.rootNodes[0];
|
|
1955
|
+
}
|
|
1974
1956
|
registerComponentFactory(componentOrComponents) {
|
|
1975
1957
|
const app = this.ngModuleRef.instance.appName;
|
|
1976
1958
|
this.getPlantAppRef(app).subscribe(appRef => {
|
|
@@ -2030,6 +2012,95 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
|
|
|
2030
2012
|
}] }];
|
|
2031
2013
|
} });
|
|
2032
2014
|
|
|
2015
|
+
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
2016
|
+
class PlanetComponentOutlet {
|
|
2017
|
+
constructor(elementRef, planetComponentLoader, ngZone) {
|
|
2018
|
+
this.elementRef = elementRef;
|
|
2019
|
+
this.planetComponentLoader = planetComponentLoader;
|
|
2020
|
+
this.ngZone = ngZone;
|
|
2021
|
+
this.planetComponentLoaded = new EventEmitter();
|
|
2022
|
+
this.destroyed$ = new Subject();
|
|
2023
|
+
}
|
|
2024
|
+
ngOnChanges(changes) {
|
|
2025
|
+
if (this.planetComponentOutlet && !changes.planetComponentOutlet.isFirstChange()) {
|
|
2026
|
+
this.loadComponent();
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
ngAfterViewInit() {
|
|
2030
|
+
this.loadComponent();
|
|
2031
|
+
}
|
|
2032
|
+
loadComponent() {
|
|
2033
|
+
this.clear();
|
|
2034
|
+
if (this.planetComponentOutlet && this.planetComponentOutletApp) {
|
|
2035
|
+
this.planetComponentLoader
|
|
2036
|
+
.load(this.planetComponentOutletApp, this.planetComponentOutlet, {
|
|
2037
|
+
container: this.elementRef.nativeElement,
|
|
2038
|
+
initialState: this.planetComponentOutletInitialState
|
|
2039
|
+
})
|
|
2040
|
+
.pipe(takeUntil(this.destroyed$))
|
|
2041
|
+
.subscribe(componentRef => {
|
|
2042
|
+
this.componentRef = componentRef;
|
|
2043
|
+
this.ngZone.run(() => {
|
|
2044
|
+
Promise.resolve().then(() => {
|
|
2045
|
+
this.planetComponentLoaded.emit(this.componentRef);
|
|
2046
|
+
});
|
|
2047
|
+
});
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
ngOnDestroy() {
|
|
2052
|
+
this.clear();
|
|
2053
|
+
this.destroyed$.complete();
|
|
2054
|
+
}
|
|
2055
|
+
clear() {
|
|
2056
|
+
var _a;
|
|
2057
|
+
(_a = this.componentRef) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
2058
|
+
this.destroyed$.next();
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
PlanetComponentOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: PlanetComponentOutlet, deps: [{ token: i0.ElementRef }, { token: PlanetComponentLoader }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2062
|
+
PlanetComponentOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.2", type: PlanetComponentOutlet, selector: "[planetComponentOutlet]", inputs: { planetComponentOutlet: "planetComponentOutlet", planetComponentOutletApp: "planetComponentOutletApp", planetComponentOutletInitialState: "planetComponentOutletInitialState" }, outputs: { planetComponentLoaded: "planetComponentLoaded" }, usesOnChanges: true, ngImport: i0 });
|
|
2063
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: PlanetComponentOutlet, decorators: [{
|
|
2064
|
+
type: Directive,
|
|
2065
|
+
args: [{
|
|
2066
|
+
selector: '[planetComponentOutlet]'
|
|
2067
|
+
}]
|
|
2068
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: PlanetComponentLoader }, { type: i0.NgZone }]; }, propDecorators: { planetComponentOutlet: [{
|
|
2069
|
+
type: Input
|
|
2070
|
+
}], planetComponentOutletApp: [{
|
|
2071
|
+
type: Input
|
|
2072
|
+
}], planetComponentOutletInitialState: [{
|
|
2073
|
+
type: Input
|
|
2074
|
+
}], planetComponentLoaded: [{
|
|
2075
|
+
type: Output
|
|
2076
|
+
}] } });
|
|
2077
|
+
|
|
2078
|
+
class NgxPlanetModule {
|
|
2079
|
+
static forRoot(apps) {
|
|
2080
|
+
return {
|
|
2081
|
+
ngModule: NgxPlanetModule,
|
|
2082
|
+
providers: [
|
|
2083
|
+
{
|
|
2084
|
+
provide: PLANET_APPLICATIONS,
|
|
2085
|
+
useValue: apps
|
|
2086
|
+
}
|
|
2087
|
+
]
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
NgxPlanetModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2092
|
+
NgxPlanetModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, declarations: [EmptyComponent, PlanetComponentOutlet], imports: [HttpClientModule], exports: [HttpClientModule, EmptyComponent, PlanetComponentOutlet] });
|
|
2093
|
+
NgxPlanetModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, imports: [HttpClientModule, HttpClientModule] });
|
|
2094
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, decorators: [{
|
|
2095
|
+
type: NgModule,
|
|
2096
|
+
args: [{
|
|
2097
|
+
declarations: [EmptyComponent, PlanetComponentOutlet],
|
|
2098
|
+
imports: [HttpClientModule],
|
|
2099
|
+
providers: [],
|
|
2100
|
+
exports: [HttpClientModule, EmptyComponent, PlanetComponentOutlet]
|
|
2101
|
+
}]
|
|
2102
|
+
}] });
|
|
2103
|
+
|
|
2033
2104
|
class PlantComponentConfig {
|
|
2034
2105
|
constructor() {
|
|
2035
2106
|
/** Data being injected into the child component. */
|
|
@@ -2045,5 +2116,5 @@ class PlantComponentConfig {
|
|
|
2045
2116
|
* Generated bundle index. Do not edit.
|
|
2046
2117
|
*/
|
|
2047
2118
|
|
|
2048
|
-
export { ApplicationStatus, AssetsLoader, EmptyComponent, GlobalEventDispatcher, NgxPlanetModule, PLANET_APPLICATIONS, Planet, PlanetApplicationLoader, PlanetApplicationRef, PlanetApplicationService, PlanetComponentLoader, PlanetComponentRef, PlanetPortalApplication, PlantComponentConfig, SwitchModes, defineApplication, getPlanetApplicationRef, getPortalApplicationData };
|
|
2119
|
+
export { ApplicationStatus, AssetsLoader, EmptyComponent, GlobalEventDispatcher, NgxPlanetModule, PLANET_APPLICATIONS, Planet, PlanetApplicationLoader, PlanetApplicationRef, PlanetApplicationService, PlanetComponentLoader, PlanetComponentOutlet, PlanetComponentRef, PlanetPortalApplication, PlantComponentConfig, SwitchModes, defineApplication, getPlanetApplicationRef, getPortalApplicationData };
|
|
2049
2120
|
//# sourceMappingURL=worktile-planet.mjs.map
|