@worktile/planet 14.0.0 → 14.1.1
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 +18 -0
- package/README.md +29 -3
- 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 +42 -32
- 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 +132 -59
- package/fesm2015/worktile-planet.mjs.map +1 -1
- package/fesm2020/worktile-planet.mjs +131 -59
- 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, createComponent, 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,55 @@ 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
|
-
const componentFactoryResolver = appModuleRef.componentFactoryResolver;
|
|
1949
1929
|
const appRef = this.applicationRef;
|
|
1950
1930
|
const injector = this.createInjector(appModuleRef, plantComponentRef);
|
|
1951
|
-
const
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
}
|
|
1960
|
-
const componentPortal = new ComponentPortal(plantComponent.component, null);
|
|
1961
|
-
const componentRef = portalOutlet.attachComponentPortal(componentPortal);
|
|
1931
|
+
const container = this.getContainerElement(config);
|
|
1932
|
+
const componentRef = createComponent(plantComponent.component, {
|
|
1933
|
+
environmentInjector: appModuleRef.injector,
|
|
1934
|
+
elementInjector: injector
|
|
1935
|
+
});
|
|
1936
|
+
appRef.attachView(componentRef.hostView);
|
|
1937
|
+
const componentRootNode = this.getComponentRootNode(componentRef);
|
|
1938
|
+
this.insertComponentRootNodeToContainer(container, componentRootNode, config.hostClass || config.wrapperClass);
|
|
1962
1939
|
if (config.initialState) {
|
|
1963
1940
|
Object.assign(componentRef.instance, config.initialState);
|
|
1964
1941
|
}
|
|
1965
1942
|
plantComponentRef.componentInstance = componentRef.instance;
|
|
1966
1943
|
plantComponentRef.componentRef = componentRef;
|
|
1967
|
-
plantComponentRef.
|
|
1944
|
+
plantComponentRef.hostElement = componentRootNode;
|
|
1968
1945
|
plantComponentRef.dispose = () => {
|
|
1969
|
-
|
|
1970
|
-
|
|
1946
|
+
if (appRef.viewCount > 0) {
|
|
1947
|
+
appRef.detachView(componentRef.hostView);
|
|
1948
|
+
}
|
|
1949
|
+
componentRef === null || componentRef === void 0 ? void 0 : componentRef.destroy();
|
|
1950
|
+
componentRootNode.remove();
|
|
1971
1951
|
};
|
|
1972
1952
|
return plantComponentRef;
|
|
1973
1953
|
}
|
|
1954
|
+
/** Gets the root HTMLElement for an instantiated component. */
|
|
1955
|
+
getComponentRootNode(componentRef) {
|
|
1956
|
+
return componentRef.hostView.rootNodes[0];
|
|
1957
|
+
}
|
|
1974
1958
|
registerComponentFactory(componentOrComponents) {
|
|
1975
1959
|
const app = this.ngModuleRef.instance.appName;
|
|
1976
1960
|
this.getPlantAppRef(app).subscribe(appRef => {
|
|
@@ -2030,6 +2014,95 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImpor
|
|
|
2030
2014
|
}] }];
|
|
2031
2015
|
} });
|
|
2032
2016
|
|
|
2017
|
+
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
2018
|
+
class PlanetComponentOutlet {
|
|
2019
|
+
constructor(elementRef, planetComponentLoader, ngZone) {
|
|
2020
|
+
this.elementRef = elementRef;
|
|
2021
|
+
this.planetComponentLoader = planetComponentLoader;
|
|
2022
|
+
this.ngZone = ngZone;
|
|
2023
|
+
this.planetComponentLoaded = new EventEmitter();
|
|
2024
|
+
this.destroyed$ = new Subject();
|
|
2025
|
+
}
|
|
2026
|
+
ngOnChanges(changes) {
|
|
2027
|
+
if (this.planetComponentOutlet && !changes.planetComponentOutlet.isFirstChange()) {
|
|
2028
|
+
this.loadComponent();
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
ngAfterViewInit() {
|
|
2032
|
+
this.loadComponent();
|
|
2033
|
+
}
|
|
2034
|
+
loadComponent() {
|
|
2035
|
+
this.clear();
|
|
2036
|
+
if (this.planetComponentOutlet && this.planetComponentOutletApp) {
|
|
2037
|
+
this.planetComponentLoader
|
|
2038
|
+
.load(this.planetComponentOutletApp, this.planetComponentOutlet, {
|
|
2039
|
+
container: this.elementRef.nativeElement,
|
|
2040
|
+
initialState: this.planetComponentOutletInitialState
|
|
2041
|
+
})
|
|
2042
|
+
.pipe(takeUntil(this.destroyed$))
|
|
2043
|
+
.subscribe(componentRef => {
|
|
2044
|
+
this.componentRef = componentRef;
|
|
2045
|
+
this.ngZone.run(() => {
|
|
2046
|
+
Promise.resolve().then(() => {
|
|
2047
|
+
this.planetComponentLoaded.emit(this.componentRef);
|
|
2048
|
+
});
|
|
2049
|
+
});
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
ngOnDestroy() {
|
|
2054
|
+
this.clear();
|
|
2055
|
+
this.destroyed$.complete();
|
|
2056
|
+
}
|
|
2057
|
+
clear() {
|
|
2058
|
+
var _a;
|
|
2059
|
+
(_a = this.componentRef) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
2060
|
+
this.destroyed$.next();
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
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 });
|
|
2064
|
+
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 });
|
|
2065
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: PlanetComponentOutlet, decorators: [{
|
|
2066
|
+
type: Directive,
|
|
2067
|
+
args: [{
|
|
2068
|
+
selector: '[planetComponentOutlet]'
|
|
2069
|
+
}]
|
|
2070
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: PlanetComponentLoader }, { type: i0.NgZone }]; }, propDecorators: { planetComponentOutlet: [{
|
|
2071
|
+
type: Input
|
|
2072
|
+
}], planetComponentOutletApp: [{
|
|
2073
|
+
type: Input
|
|
2074
|
+
}], planetComponentOutletInitialState: [{
|
|
2075
|
+
type: Input
|
|
2076
|
+
}], planetComponentLoaded: [{
|
|
2077
|
+
type: Output
|
|
2078
|
+
}] } });
|
|
2079
|
+
|
|
2080
|
+
class NgxPlanetModule {
|
|
2081
|
+
static forRoot(apps) {
|
|
2082
|
+
return {
|
|
2083
|
+
ngModule: NgxPlanetModule,
|
|
2084
|
+
providers: [
|
|
2085
|
+
{
|
|
2086
|
+
provide: PLANET_APPLICATIONS,
|
|
2087
|
+
useValue: apps
|
|
2088
|
+
}
|
|
2089
|
+
]
|
|
2090
|
+
};
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
NgxPlanetModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2094
|
+
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] });
|
|
2095
|
+
NgxPlanetModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, imports: [HttpClientModule, HttpClientModule] });
|
|
2096
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: NgxPlanetModule, decorators: [{
|
|
2097
|
+
type: NgModule,
|
|
2098
|
+
args: [{
|
|
2099
|
+
declarations: [EmptyComponent, PlanetComponentOutlet],
|
|
2100
|
+
imports: [HttpClientModule],
|
|
2101
|
+
providers: [],
|
|
2102
|
+
exports: [HttpClientModule, EmptyComponent, PlanetComponentOutlet]
|
|
2103
|
+
}]
|
|
2104
|
+
}] });
|
|
2105
|
+
|
|
2033
2106
|
class PlantComponentConfig {
|
|
2034
2107
|
constructor() {
|
|
2035
2108
|
/** Data being injected into the child component. */
|
|
@@ -2045,5 +2118,5 @@ class PlantComponentConfig {
|
|
|
2045
2118
|
* Generated bundle index. Do not edit.
|
|
2046
2119
|
*/
|
|
2047
2120
|
|
|
2048
|
-
export { ApplicationStatus, AssetsLoader, EmptyComponent, GlobalEventDispatcher, NgxPlanetModule, PLANET_APPLICATIONS, Planet, PlanetApplicationLoader, PlanetApplicationRef, PlanetApplicationService, PlanetComponentLoader, PlanetComponentRef, PlanetPortalApplication, PlantComponentConfig, SwitchModes, defineApplication, getPlanetApplicationRef, getPortalApplicationData };
|
|
2121
|
+
export { ApplicationStatus, AssetsLoader, EmptyComponent, GlobalEventDispatcher, NgxPlanetModule, PLANET_APPLICATIONS, Planet, PlanetApplicationLoader, PlanetApplicationRef, PlanetApplicationService, PlanetComponentLoader, PlanetComponentOutlet, PlanetComponentRef, PlanetPortalApplication, PlantComponentConfig, SwitchModes, defineApplication, getPlanetApplicationRef, getPortalApplicationData };
|
|
2049
2122
|
//# sourceMappingURL=worktile-planet.mjs.map
|