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