@worktile/planet 10.0.0 → 12.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/.all-contributorsrc +84 -0
- package/.circleci/config.yml +17 -0
- package/.coveralls.yml +1 -0
- package/.docgeni/public/assets/favicon.ico +0 -0
- package/.docgeni/public/index.html +13 -0
- package/.docgenirc.js +35 -0
- package/.dockerignore +1 -0
- package/.editorconfig +22 -0
- package/.github/FUNDING.yml +12 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.prettierignore +7 -0
- package/.prettierrc +28 -0
- package/.travis.yml +26 -0
- package/.wpmrc.js +11 -0
- package/CHANGELOG.md +391 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/Dockerfile +11 -0
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/README.zh-CN.md +307 -0
- package/SECURITY.md +21 -0
- package/angular.json +373 -0
- package/commitlint.config.js +6 -0
- package/docs/api/defineApplication.md +46 -0
- package/docs/api/globalEventDispatcher.md +51 -0
- package/docs/api/index.md +5 -0
- package/docs/api/planet.md +117 -0
- package/docs/guides/getting-started.md +174 -0
- package/docs/guides/index.md +5 -0
- package/docs/guides/intro.md +216 -0
- package/examples/app1/browserslist +11 -0
- package/examples/app1/extra-webpack.config.js +33 -0
- package/examples/app1/karma.conf.js +31 -0
- package/examples/app1/postcss.config.js +1 -0
- package/examples/app1/src/app/app.module.ts +44 -0
- package/examples/app1/src/app/app.routing.ts +49 -0
- package/examples/app1/src/app/counter.service.ts +16 -0
- package/examples/app1/src/app/dashboard/dashboard.component.html +51 -0
- package/examples/app1/src/app/dashboard/dashboard.component.ts +70 -0
- package/examples/app1/src/app/detail/detail.component.html +8 -0
- package/examples/app1/src/app/detail/detail.component.ts +18 -0
- package/examples/app1/src/app/overlay.ts +26 -0
- package/examples/app1/src/app/projects/dialog/projects-dialog.component.html +10 -0
- package/examples/app1/src/app/projects/dialog/projects-dialog.component.ts +41 -0
- package/examples/app1/src/app/projects/projects.component.ts +33 -0
- package/examples/app1/src/app/root/root.component.css +3 -0
- package/examples/app1/src/app/root/root.component.html +16 -0
- package/examples/app1/src/app/root/root.component.ts +35 -0
- package/examples/app1/src/app/services/initialized-data.resolver.ts +15 -0
- package/examples/app1/src/app/shared.module.ts +57 -0
- package/examples/app1/src/app/user/detail/user-detail.component.html +5 -0
- package/examples/app1/src/app/user/detail/user-detail.component.ts +20 -0
- package/examples/app1/src/app/user/user-list.component.html +7 -0
- package/examples/app1/src/app/user/user-list.component.ts +20 -0
- package/examples/app1/src/app/user/user.module.ts +31 -0
- package/examples/app1/src/assets/.gitkeep +0 -0
- package/examples/app1/src/assets/github.png +0 -0
- package/examples/app1/src/assets/main.css +3 -0
- package/examples/app1/src/environments/environment.prod.ts +3 -0
- package/examples/app1/src/environments/environment.ts +16 -0
- package/examples/app1/src/favicon.ico +0 -0
- package/examples/app1/src/index.html +14 -0
- package/examples/app1/src/main.ts +35 -0
- package/examples/app1/src/polyfills.ts +84 -0
- package/examples/app1/src/styles.scss +35 -0
- package/examples/app1/src/test.ts +14 -0
- package/examples/app1/temp.js +221 -0
- package/examples/app1/tsconfig.app.json +10 -0
- package/examples/app1/tsconfig.spec.json +18 -0
- package/examples/app1/tslint.json +17 -0
- package/examples/app1/webpack.config.js +127 -0
- package/examples/app2/browserslist +11 -0
- package/examples/app2/extra-webpack.config.js +32 -0
- package/examples/app2/karma.conf.js +31 -0
- package/examples/app2/src/app/app.module.ts +90 -0
- package/examples/app2/src/app/dashboard/dashboard.component.html +21 -0
- package/examples/app2/src/app/dashboard/dashboard.component.ts +27 -0
- package/examples/app2/src/app/overlay.ts +26 -0
- package/examples/app2/src/app/projects/detail/detail.component.html +16 -0
- package/examples/app2/src/app/projects/detail/detail.component.ts +21 -0
- package/examples/app2/src/app/projects/project-list.component.html +29 -0
- package/examples/app2/src/app/projects/project-list.component.ts +58 -0
- package/examples/app2/src/app/projects/project.resolver.ts +15 -0
- package/examples/app2/src/app/projects/projects.service.ts +28 -0
- package/examples/app2/src/app/projects/tasks/tasks.component.html +10 -0
- package/examples/app2/src/app/projects/tasks/tasks.component.ts +16 -0
- package/examples/app2/src/app/projects/view/view.component.html +1 -0
- package/examples/app2/src/app/projects/view/view.component.ts +20 -0
- package/examples/app2/src/app/root/root.component.html +14 -0
- package/examples/app2/src/app/root/root.component.scss +12 -0
- package/examples/app2/src/app/root/root.component.ts +28 -0
- package/examples/app2/src/app/shared.module.ts +59 -0
- package/examples/app2/src/assets/.gitkeep +0 -0
- package/examples/app2/src/environments/environment.prod.ts +3 -0
- package/examples/app2/src/environments/environment.ts +16 -0
- package/examples/app2/src/favicon.ico +0 -0
- package/examples/app2/src/index.html +14 -0
- package/examples/app2/src/main.ts +36 -0
- package/examples/app2/src/polyfills.ts +84 -0
- package/examples/app2/src/styles.scss +28 -0
- package/examples/app2/src/test.ts +14 -0
- package/examples/app2/tsconfig.app.json +10 -0
- package/examples/app2/tsconfig.spec.json +18 -0
- package/examples/app2/tslint.json +7 -0
- package/examples/app2/webpack.config.js +92 -0
- package/examples/common/app-root-context.ts +10 -0
- package/examples/common/cache.ts +82 -0
- package/examples/common/index.ts +13 -0
- package/examples/common/module.ts +10 -0
- package/examples/common/overlay-container.service.ts +28 -0
- package/examples/common/section-card/section-card.component.html +5 -0
- package/examples/common/section-card/section-card.component.scss +15 -0
- package/examples/common/section-card/section-card.component.ts +11 -0
- package/examples/common/utils.ts +0 -0
- package/examples/portal/src/app/a-detail/a-detail.component.html +8 -0
- package/examples/portal/src/app/a-detail/a-detail.component.ts +18 -0
- package/examples/portal/src/app/about/about.component.html +27 -0
- package/examples/portal/src/app/about/about.component.scss +0 -0
- package/examples/portal/src/app/about/about.component.spec.ts +26 -0
- package/examples/portal/src/app/about/about.component.ts +26 -0
- package/examples/portal/src/app/app-routing.module.ts +57 -0
- package/examples/portal/src/app/app.component.html +73 -0
- package/examples/portal/src/app/app.component.scss +58 -0
- package/examples/portal/src/app/app.component.spec.ts +33 -0
- package/examples/portal/src/app/app.component.ts +111 -0
- package/examples/portal/src/app/app.module.ts +64 -0
- package/examples/portal/src/app/custom-settings.service.ts +44 -0
- package/examples/portal/src/app/overlay.ts +26 -0
- package/examples/portal/src/app/settings/settings.component.html +31 -0
- package/examples/portal/src/app/settings/settings.component.scss +3 -0
- package/examples/portal/src/app/settings/settings.component.ts +43 -0
- package/examples/portal/src/assets/.gitkeep +0 -0
- package/examples/portal/src/assets/apps.json +29 -0
- package/examples/portal/src/assets/icons/sprite.defs.svg +1 -0
- package/examples/portal/src/assets/images/logo.svg +16 -0
- package/examples/portal/src/assets/ngx-planet-micro-front-end.gif +0 -0
- package/examples/portal/src/browserslist +11 -0
- package/examples/portal/src/environments/environment.prod.ts +3 -0
- package/examples/portal/src/environments/environment.ts +16 -0
- package/examples/portal/src/extra-webpack.config.js +32 -0
- package/examples/portal/src/favicon.ico +0 -0
- package/examples/portal/src/index.html +14 -0
- package/examples/portal/src/karma.conf.js +31 -0
- package/examples/portal/src/main.ts +18 -0
- package/examples/portal/src/polyfills.ts +84 -0
- package/examples/portal/src/reboot.scss +14 -0
- package/examples/portal/src/styles.scss +14 -0
- package/examples/portal/src/test.ts +14 -0
- package/examples/portal/src/tsconfig.app.json +10 -0
- package/examples/portal/src/tsconfig.spec.json +9 -0
- package/examples/portal/src/tslint.json +7 -0
- package/extra-webpack.config.js +5 -0
- package/nginx.conf +17 -0
- package/package.json +120 -15
- package/packages/planet/karma.conf.js +37 -0
- package/packages/planet/ng-package.json +7 -0
- package/packages/planet/package.json +10 -0
- package/packages/planet/src/application/planet-application-loader.spec.ts +1102 -0
- package/packages/planet/src/application/planet-application-loader.ts +549 -0
- package/packages/planet/src/application/planet-application-ref.spec.ts +233 -0
- package/packages/planet/src/application/planet-application-ref.ts +131 -0
- package/packages/planet/src/application/planet-application.service.spec.ts +145 -0
- package/packages/planet/src/application/planet-application.service.ts +88 -0
- package/packages/planet/src/application/portal-application.spec.ts +53 -0
- package/packages/planet/src/application/portal-application.ts +28 -0
- package/packages/planet/src/assets-loader.spec.ts +689 -0
- package/packages/planet/src/assets-loader.ts +247 -0
- package/packages/planet/src/component/planet-component-loader.spec.ts +187 -0
- package/packages/planet/src/component/planet-component-loader.ts +173 -0
- package/{component/planet-component-ref.d.ts → packages/planet/src/component/planet-component-ref.ts} +3 -2
- package/{component/plant-component.config.d.ts → packages/planet/src/component/plant-component.config.ts} +4 -3
- package/packages/planet/src/debug.spec.ts +58 -0
- package/packages/planet/src/debug.ts +66 -0
- package/packages/planet/src/empty/empty.component.spec.ts +34 -0
- package/packages/planet/src/empty/empty.component.ts +7 -0
- package/packages/planet/src/global-event-dispatcher.spec.ts +81 -0
- package/packages/planet/src/global-event-dispatcher.ts +82 -0
- package/packages/planet/src/global-planet.spec.ts +39 -0
- package/packages/planet/src/global-planet.ts +73 -0
- package/packages/planet/src/helpers.spec.ts +242 -0
- package/packages/planet/src/helpers.ts +125 -0
- package/packages/planet/src/module.spec.ts +79 -0
- package/packages/planet/src/module.ts +25 -0
- package/packages/planet/src/planet.class.ts +59 -0
- package/packages/planet/src/planet.spec.ts +226 -0
- package/packages/planet/src/planet.ts +113 -0
- package/{public-api.d.ts → packages/planet/src/public-api.ts} +4 -0
- package/packages/planet/src/sandbox/constants.ts +6 -0
- package/packages/planet/src/sandbox/exec.ts +22 -0
- package/packages/planet/src/sandbox/index.ts +24 -0
- package/packages/planet/src/sandbox/proxy/patches/document.ts +13 -0
- package/packages/planet/src/sandbox/proxy/patches/eventListener.ts +49 -0
- package/packages/planet/src/sandbox/proxy/patches/index.ts +13 -0
- package/packages/planet/src/sandbox/proxy/patches/storage.ts +53 -0
- package/packages/planet/src/sandbox/proxy/patches/timer.ts +50 -0
- package/packages/planet/src/sandbox/proxy/proxies/common.ts +137 -0
- package/packages/planet/src/sandbox/proxy/proxies/document.ts +140 -0
- package/packages/planet/src/sandbox/proxy/proxies/window.ts +176 -0
- package/packages/planet/src/sandbox/proxy/proxy-sandbox.ts +59 -0
- package/packages/planet/src/sandbox/proxy/types.ts +20 -0
- package/packages/planet/src/sandbox/sandbox.ts +20 -0
- package/packages/planet/src/sandbox/snapshot/snapshot-sandbox.ts +12 -0
- package/packages/planet/src/sandbox/types.ts +1 -0
- package/packages/planet/src/test.ts +16 -0
- package/packages/planet/src/testing/app1.module.ts +34 -0
- package/packages/planet/src/testing/app2.module.ts +24 -0
- package/packages/planet/src/testing/applications.ts +58 -0
- package/packages/planet/src/testing/index.ts +2 -0
- package/packages/planet/src/testing/utils.ts +31 -0
- package/packages/planet/tsconfig.lib.json +27 -0
- package/packages/planet/tsconfig.lib.prod.json +9 -0
- package/packages/planet/tsconfig.spec.json +17 -0
- package/packages/planet/tslint.json +7 -0
- package/postcss.config.js +3 -0
- package/proxy.conf.js +15 -0
- package/tsconfig.json +23 -0
- package/tslint.json +80 -0
- package/application/planet-application-loader.d.ts +0 -68
- package/application/planet-application-ref.d.ts +0 -32
- package/application/planet-application.service.d.ts +0 -18
- package/application/portal-application.d.ts +0 -14
- package/assets-loader.d.ts +0 -23
- package/bundles/worktile-planet.umd.js +0 -1670
- package/bundles/worktile-planet.umd.js.map +0 -1
- package/bundles/worktile-planet.umd.min.js +0 -16
- package/bundles/worktile-planet.umd.min.js.map +0 -1
- package/component/planet-component-loader.d.ts +0 -27
- package/empty/empty.component.d.ts +0 -2
- package/esm2015/application/planet-application-loader.js +0 -417
- package/esm2015/application/planet-application-ref.js +0 -86
- package/esm2015/application/planet-application.service.js +0 -87
- package/esm2015/application/portal-application.js +0 -16
- package/esm2015/assets-loader.js +0 -165
- package/esm2015/component/planet-component-loader.js +0 -157
- package/esm2015/component/planet-component-ref.js +0 -3
- package/esm2015/component/plant-component.config.js +0 -7
- package/esm2015/empty/empty.component.js +0 -10
- package/esm2015/global-event-dispatcher.js +0 -71
- package/esm2015/global-planet.js +0 -51
- package/esm2015/helpers.js +0 -116
- package/esm2015/module.js +0 -27
- package/esm2015/planet.class.js +0 -9
- package/esm2015/planet.js +0 -86
- package/esm2015/public-api.js +0 -18
- package/esm2015/worktile-planet.js +0 -6
- package/fesm2015/worktile-planet.js +0 -1257
- package/fesm2015/worktile-planet.js.map +0 -1
- package/global-event-dispatcher.d.ts +0 -19
- package/global-planet.d.ts +0 -22
- package/helpers.d.ts +0 -37
- package/module.d.ts +0 -5
- package/planet.class.d.ts +0 -34
- package/planet.d.ts +0 -24
- package/worktile-planet.d.ts +0 -5
- package/worktile-planet.metadata.json +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Global } from '../types';
|
|
2
|
+
|
|
3
|
+
// SandboxInstance 主要是为了解决循环依赖
|
|
4
|
+
export interface ProxySandboxInstance {
|
|
5
|
+
app: string;
|
|
6
|
+
|
|
7
|
+
running: boolean;
|
|
8
|
+
|
|
9
|
+
global: Global;
|
|
10
|
+
|
|
11
|
+
rewriteVariables: PropertyKey[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SandboxPatchHandler {
|
|
15
|
+
rewrite?: Record<PropertyKey, any>;
|
|
16
|
+
init?: () => void;
|
|
17
|
+
destroy?: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type SandboxPatch = (sandbox?: ProxySandboxInstance) => SandboxPatchHandler;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { execScript } from './exec';
|
|
2
|
+
import { Global } from './types';
|
|
3
|
+
|
|
4
|
+
export interface SandboxOptions {
|
|
5
|
+
strictGlobal?: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export abstract class Sandbox {
|
|
9
|
+
options!: SandboxOptions;
|
|
10
|
+
|
|
11
|
+
global!: Global;
|
|
12
|
+
|
|
13
|
+
abstract start(): void;
|
|
14
|
+
|
|
15
|
+
abstract destroy(): void;
|
|
16
|
+
|
|
17
|
+
execScript(code: string, url = '') {
|
|
18
|
+
execScript(code, url, this.global, !!this.options.strictGlobal);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Global = Record<PropertyKey, any>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
|
2
|
+
|
|
3
|
+
// import 'core-js/es7/reflect';
|
|
4
|
+
import 'zone.js';
|
|
5
|
+
import 'zone.js/testing';
|
|
6
|
+
import { getTestBed } from '@angular/core/testing';
|
|
7
|
+
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
|
8
|
+
|
|
9
|
+
declare const require: any;
|
|
10
|
+
|
|
11
|
+
// First, initialize the Angular testing environment.
|
|
12
|
+
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
|
|
13
|
+
// Then we find all the tests.
|
|
14
|
+
const context = require.context('./', true, /\.spec\.ts$/);
|
|
15
|
+
// And load the modules.
|
|
16
|
+
context.keys().map(context);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Component, NgModule } from '@angular/core';
|
|
2
|
+
import { RouterModule } from '@angular/router';
|
|
3
|
+
import { PlanetComponentLoader } from '../component/planet-component-loader';
|
|
4
|
+
import { PlanetApplicationLoader } from '../application/planet-application-loader';
|
|
5
|
+
|
|
6
|
+
export const app1Name = 'app1';
|
|
7
|
+
|
|
8
|
+
@Component({
|
|
9
|
+
selector: 'app1-projects',
|
|
10
|
+
template: `
|
|
11
|
+
projects is work
|
|
12
|
+
`
|
|
13
|
+
})
|
|
14
|
+
export class App1ProjectsComponent {}
|
|
15
|
+
|
|
16
|
+
@NgModule({
|
|
17
|
+
declarations: [App1ProjectsComponent],
|
|
18
|
+
entryComponents: [App1ProjectsComponent],
|
|
19
|
+
imports: [RouterModule.forChild([])],
|
|
20
|
+
providers: [
|
|
21
|
+
PlanetComponentLoader,
|
|
22
|
+
{
|
|
23
|
+
provide: PlanetApplicationLoader,
|
|
24
|
+
useValue: {
|
|
25
|
+
preload: () => {}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
})
|
|
30
|
+
export class App1Module {
|
|
31
|
+
constructor(private componentLoader: PlanetComponentLoader) {
|
|
32
|
+
// componentLoader.register([{ name: 'app1-projects', component: App1ProjectsComponent }]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Component, NgModule } from '@angular/core';
|
|
2
|
+
import { RouterModule } from '@angular/router';
|
|
3
|
+
import { PlanetApplicationLoader } from '../application/planet-application-loader';
|
|
4
|
+
import { PlanetComponentLoader } from '../component/planet-component-loader';
|
|
5
|
+
|
|
6
|
+
export const app2Name = 'app2';
|
|
7
|
+
|
|
8
|
+
@NgModule({
|
|
9
|
+
declarations: [],
|
|
10
|
+
entryComponents: [],
|
|
11
|
+
imports: [RouterModule.forChild([])],
|
|
12
|
+
providers: [
|
|
13
|
+
PlanetComponentLoader,
|
|
14
|
+
{
|
|
15
|
+
provide: PlanetApplicationLoader,
|
|
16
|
+
useValue: {
|
|
17
|
+
preload: () => {}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
})
|
|
22
|
+
export class App2Module {
|
|
23
|
+
constructor() {}
|
|
24
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { SwitchModes } from '../planet.class';
|
|
2
|
+
const app1 = {
|
|
3
|
+
name: 'app1',
|
|
4
|
+
hostParent: '.host-selector',
|
|
5
|
+
selector: 'app1-root',
|
|
6
|
+
stylePrefix: 'app1-prefix',
|
|
7
|
+
routerPathPrefix: '/app1',
|
|
8
|
+
hostClass: 'app1-host',
|
|
9
|
+
preload: false,
|
|
10
|
+
switchMode: SwitchModes.default,
|
|
11
|
+
resourcePathPrefix: '/static/app1/',
|
|
12
|
+
styles: ['styles/main.css'],
|
|
13
|
+
scripts: ['vendor.js', 'main.js'],
|
|
14
|
+
loadSerial: false,
|
|
15
|
+
manifest: '',
|
|
16
|
+
extra: {
|
|
17
|
+
appName: '应用1'
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const app1WithManifest = {
|
|
22
|
+
...app1,
|
|
23
|
+
manifest: '/static/app/manifest.json'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const app1WithPreload = {
|
|
27
|
+
...app1,
|
|
28
|
+
preload: true
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const app2 = {
|
|
32
|
+
name: 'app2',
|
|
33
|
+
hostParent: '.host-selector',
|
|
34
|
+
selector: 'app2-root',
|
|
35
|
+
routerPathPrefix: '/app2',
|
|
36
|
+
hostClass: 'app2-host',
|
|
37
|
+
preload: false,
|
|
38
|
+
switchMode: SwitchModes.coexist,
|
|
39
|
+
resourcePathPrefix: '/static/app2',
|
|
40
|
+
styles: ['styles/main.css'],
|
|
41
|
+
scripts: ['vendor.js', 'main.js'],
|
|
42
|
+
loadSerial: false,
|
|
43
|
+
extra: {
|
|
44
|
+
appName: '应用2'
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const app2WithManifest = {
|
|
49
|
+
...app2,
|
|
50
|
+
manifest: '/static/app/manifest.json'
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const app2WithPreload = {
|
|
54
|
+
...app2,
|
|
55
|
+
preload: true
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { app1, app1WithManifest, app1WithPreload, app2, app2WithManifest, app2WithPreload };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { setDebugFactory, clearDebugFactory } from '../debug';
|
|
2
|
+
|
|
3
|
+
export function roundNumber(minNum: number, maxNum?: number): number {
|
|
4
|
+
switch (arguments.length) {
|
|
5
|
+
case 1:
|
|
6
|
+
return parseInt((Math.random() * minNum + 1) as any, 10);
|
|
7
|
+
case 2:
|
|
8
|
+
return parseInt((Math.random() * (maxNum! - minNum + 1) + minNum) as any, 10);
|
|
9
|
+
default:
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function sample<T>(items: T[]): T {
|
|
15
|
+
const num = roundNumber(1, items.length);
|
|
16
|
+
return items[num - 1];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function enableDebugForTest() {
|
|
20
|
+
const debugFactory = (namespace: string) => {
|
|
21
|
+
return (formatter: string) => {
|
|
22
|
+
console.log(`[${namespace}] ${formatter}`);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
setDebugFactory(debugFactory as any);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function disableDebugForTest() {
|
|
30
|
+
clearDebugFactory();
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../out-tsc/lib",
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"target": "es2015",
|
|
7
|
+
"module": "es2015",
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"inlineSources": true,
|
|
12
|
+
"emitDecoratorMetadata": true,
|
|
13
|
+
"experimentalDecorators": true,
|
|
14
|
+
"importHelpers": true,
|
|
15
|
+
"types": [],
|
|
16
|
+
"lib": ["dom", "es2018"]
|
|
17
|
+
},
|
|
18
|
+
"angularCompilerOptions": {
|
|
19
|
+
"skipTemplateCodegen": true,
|
|
20
|
+
"strictMetadataEmit": true,
|
|
21
|
+
"fullTemplateTypeCheck": true,
|
|
22
|
+
"strictInjectionParameters": true,
|
|
23
|
+
"enableResourceInlining": true,
|
|
24
|
+
"enableIvy": false
|
|
25
|
+
},
|
|
26
|
+
"exclude": ["src/test.ts", "**/*.spec.ts"]
|
|
27
|
+
}
|
package/proxy.conf.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const PROXY_CONFIG = {};
|
|
2
|
+
|
|
3
|
+
PROXY_CONFIG['/static/app1'] = {
|
|
4
|
+
target: 'http://localhost:3001',
|
|
5
|
+
secure: false,
|
|
6
|
+
changeOrigin: false
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
PROXY_CONFIG['/static/app2'] = {
|
|
10
|
+
target: 'http://localhost:3002',
|
|
11
|
+
secure: false,
|
|
12
|
+
changeOrigin: true
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports = PROXY_CONFIG;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compileOnSave": false,
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": "./",
|
|
5
|
+
"outDir": "./dist/out-tsc",
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"declaration": false,
|
|
8
|
+
"module": "esnext",
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"emitDecoratorMetadata": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"importHelpers": true,
|
|
13
|
+
"target": "es5",
|
|
14
|
+
"typeRoots": ["node_modules/@types"],
|
|
15
|
+
"lib": ["es2018", "dom"],
|
|
16
|
+
"paths": {
|
|
17
|
+
"@demo/common": ["examples/common"],
|
|
18
|
+
"ngx-planet": ["packages/planet/src/public-api.ts"],
|
|
19
|
+
"ngx-planet/*": ["packages/planet/src/*"]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"angularCompilerOptions": {}
|
|
23
|
+
}
|
package/tslint.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rulesDirectory": ["codelyzer"],
|
|
3
|
+
"rules": {
|
|
4
|
+
"arrow-return-shorthand": true,
|
|
5
|
+
"callable-types": true,
|
|
6
|
+
"class-name": true,
|
|
7
|
+
"comment-format": [true, "check-space"],
|
|
8
|
+
"curly": true,
|
|
9
|
+
"deprecation": {
|
|
10
|
+
"severity": "warn"
|
|
11
|
+
},
|
|
12
|
+
"eofline": true,
|
|
13
|
+
"forin": true,
|
|
14
|
+
"import-blacklist": [true, "rxjs/Rx"],
|
|
15
|
+
"import-spacing": true,
|
|
16
|
+
"indent": [true, "spaces"],
|
|
17
|
+
"interface-over-type-literal": true,
|
|
18
|
+
"label-position": true,
|
|
19
|
+
"max-line-length": [true, 140],
|
|
20
|
+
"member-access": false,
|
|
21
|
+
"member-ordering": [
|
|
22
|
+
true,
|
|
23
|
+
{
|
|
24
|
+
"order": ["static-field", "instance-field", "static-method", "instance-method"]
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"no-arg": true,
|
|
28
|
+
"no-bitwise": false,
|
|
29
|
+
"no-console": [true, "debug", "info", "time", "timeEnd", "trace"],
|
|
30
|
+
"no-construct": true,
|
|
31
|
+
"no-debugger": true,
|
|
32
|
+
"no-duplicate-super": true,
|
|
33
|
+
"no-empty": false,
|
|
34
|
+
"no-empty-interface": true,
|
|
35
|
+
"no-eval": true,
|
|
36
|
+
"no-inferrable-types": [true, "ignore-params"],
|
|
37
|
+
"no-misused-new": true,
|
|
38
|
+
"no-non-null-assertion": true,
|
|
39
|
+
"no-redundant-jsdoc": true,
|
|
40
|
+
"no-shadowed-variable": true,
|
|
41
|
+
"no-string-literal": false,
|
|
42
|
+
"no-string-throw": true,
|
|
43
|
+
"no-switch-case-fall-through": true,
|
|
44
|
+
"no-trailing-whitespace": true,
|
|
45
|
+
"no-unnecessary-initializer": true,
|
|
46
|
+
"no-unused-expression": true,
|
|
47
|
+
"no-use-before-declare": true,
|
|
48
|
+
"no-var-keyword": true,
|
|
49
|
+
"object-literal-sort-keys": false,
|
|
50
|
+
"one-line": [true, "check-open-brace", "check-catch", "check-else", "check-whitespace"],
|
|
51
|
+
"prefer-const": true,
|
|
52
|
+
"quotemark": [true, "single"],
|
|
53
|
+
"radix": true,
|
|
54
|
+
"semicolon": [true, "always", "strict-bound-class-methods"],
|
|
55
|
+
"triple-equals": [true, "allow-null-check"],
|
|
56
|
+
"typedef-whitespace": [
|
|
57
|
+
true,
|
|
58
|
+
{
|
|
59
|
+
"call-signature": "nospace",
|
|
60
|
+
"index-signature": "nospace",
|
|
61
|
+
"parameter": "nospace",
|
|
62
|
+
"property-declaration": "nospace",
|
|
63
|
+
"variable-declaration": "nospace"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"unified-signatures": true,
|
|
67
|
+
"variable-name": false,
|
|
68
|
+
"whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type"],
|
|
69
|
+
"no-output-on-prefix": true,
|
|
70
|
+
"use-input-property-decorator": true,
|
|
71
|
+
"use-output-property-decorator": true,
|
|
72
|
+
"use-host-property-decorator": true,
|
|
73
|
+
"no-input-rename": true,
|
|
74
|
+
"no-output-rename": true,
|
|
75
|
+
"use-life-cycle-interface": true,
|
|
76
|
+
"use-pipe-transform-interface": true,
|
|
77
|
+
"component-class-suffix": true,
|
|
78
|
+
"directive-class-suffix": true
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { NgZone, ApplicationRef, Injector } from '@angular/core';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { AssetsLoader } from '../assets-loader';
|
|
4
|
-
import { PlanetApplication, PlanetRouterEvent, PlanetOptions } from '../planet.class';
|
|
5
|
-
import { PlanetApplicationRef } from './planet-application-ref';
|
|
6
|
-
import { PlanetApplicationService } from './planet-application.service';
|
|
7
|
-
import { Router } from '@angular/router';
|
|
8
|
-
export declare enum ApplicationStatus {
|
|
9
|
-
assetsLoading = 1,
|
|
10
|
-
assetsLoaded = 2,
|
|
11
|
-
bootstrapping = 3,
|
|
12
|
-
bootstrapped = 4,
|
|
13
|
-
active = 5,
|
|
14
|
-
loadError = 10
|
|
15
|
-
}
|
|
16
|
-
export interface AppsLoadingStartEvent {
|
|
17
|
-
shouldLoadApps: PlanetApplication[];
|
|
18
|
-
shouldUnloadApps: PlanetApplication[];
|
|
19
|
-
}
|
|
20
|
-
export interface AppStatusChangeEvent {
|
|
21
|
-
app: PlanetApplication;
|
|
22
|
-
status: ApplicationStatus;
|
|
23
|
-
}
|
|
24
|
-
export declare class PlanetApplicationLoader {
|
|
25
|
-
private assetsLoader;
|
|
26
|
-
private planetApplicationService;
|
|
27
|
-
private ngZone;
|
|
28
|
-
private firstLoad;
|
|
29
|
-
private startRouteChangeEvent;
|
|
30
|
-
private options;
|
|
31
|
-
private inProgressAppAssetsLoads;
|
|
32
|
-
private appsStatus;
|
|
33
|
-
private portalApp;
|
|
34
|
-
private routeChange$;
|
|
35
|
-
private appStatusChange$;
|
|
36
|
-
private appsLoadingStart$;
|
|
37
|
-
get appStatusChange(): Observable<AppStatusChangeEvent>;
|
|
38
|
-
get appsLoadingStart(): Observable<AppsLoadingStartEvent>;
|
|
39
|
-
loadingDone: boolean;
|
|
40
|
-
constructor(assetsLoader: AssetsLoader, planetApplicationService: PlanetApplicationService, ngZone: NgZone, router: Router, injector: Injector, applicationRef: ApplicationRef);
|
|
41
|
-
private setAppStatus;
|
|
42
|
-
private switchModeIsCoexist;
|
|
43
|
-
private errorHandler;
|
|
44
|
-
private takeOneStable;
|
|
45
|
-
private setLoadingDone;
|
|
46
|
-
private setupRouteChange;
|
|
47
|
-
private startLoadAppAssets;
|
|
48
|
-
private hideApp;
|
|
49
|
-
private showApp;
|
|
50
|
-
private destroyApp;
|
|
51
|
-
private bootstrapApp;
|
|
52
|
-
private getUnloadApps;
|
|
53
|
-
private unloadApps;
|
|
54
|
-
private preloadApps;
|
|
55
|
-
private ensurePreloadApps;
|
|
56
|
-
setOptions(options: Partial<PlanetOptions>): void;
|
|
57
|
-
/**
|
|
58
|
-
* reset route by current router
|
|
59
|
-
*/
|
|
60
|
-
reroute(event: PlanetRouterEvent): void;
|
|
61
|
-
private preloadInternal;
|
|
62
|
-
/**
|
|
63
|
-
* Preload planet application
|
|
64
|
-
* @param app app
|
|
65
|
-
* @param immediate bootstrap on stable by default, setting immediate is true, it will bootstrap immediate
|
|
66
|
-
*/
|
|
67
|
-
preload(app: PlanetApplication, immediate?: boolean): Observable<PlanetApplicationRef>;
|
|
68
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { NgModuleRef } from '@angular/core';
|
|
2
|
-
import { Router } from '@angular/router';
|
|
3
|
-
import { Observable } from 'rxjs';
|
|
4
|
-
import { PlanetPortalApplication } from './portal-application';
|
|
5
|
-
import { PlantComponentConfig } from '../component/plant-component.config';
|
|
6
|
-
import { PlanetComponentRef } from '../component/planet-component-ref';
|
|
7
|
-
export interface BootstrapOptions {
|
|
8
|
-
template: string;
|
|
9
|
-
bootstrap: BootstrapAppModule;
|
|
10
|
-
}
|
|
11
|
-
export declare type BootstrapAppModule = (portalApp?: PlanetPortalApplication) => Promise<NgModuleRef<any>>;
|
|
12
|
-
export declare type PlantComponentFactory = <TData, TComp>(componentName: string, config: PlantComponentConfig<TData>) => PlanetComponentRef<TComp>;
|
|
13
|
-
export declare class PlanetApplicationRef {
|
|
14
|
-
appModuleRef: NgModuleRef<any>;
|
|
15
|
-
template: string;
|
|
16
|
-
private innerSelector;
|
|
17
|
-
get selector(): string;
|
|
18
|
-
get bootstrapped(): boolean;
|
|
19
|
-
private name;
|
|
20
|
-
private portalApp;
|
|
21
|
-
private appModuleBootstrap;
|
|
22
|
-
private componentFactory;
|
|
23
|
-
constructor(name: string, options: BootstrapOptions);
|
|
24
|
-
private syncPortalRouteWhenNavigationEnd;
|
|
25
|
-
bootstrap(app: PlanetPortalApplication): Observable<this>;
|
|
26
|
-
getRouter(): Router;
|
|
27
|
-
getCurrentRouterStateUrl(): string;
|
|
28
|
-
navigateByUrl(url: string): void;
|
|
29
|
-
getComponentFactory(): PlantComponentFactory;
|
|
30
|
-
registerComponentFactory(componentFactory: PlantComponentFactory): void;
|
|
31
|
-
destroy(): void;
|
|
32
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PlanetApplication } from '../planet.class';
|
|
2
|
-
import { HttpClient } from '@angular/common/http';
|
|
3
|
-
import { Observable } from 'rxjs';
|
|
4
|
-
import { AssetsLoader } from '../assets-loader';
|
|
5
|
-
export declare class PlanetApplicationService {
|
|
6
|
-
private http;
|
|
7
|
-
private assetsLoader;
|
|
8
|
-
private apps;
|
|
9
|
-
private appsMap;
|
|
10
|
-
constructor(http: HttpClient, assetsLoader: AssetsLoader);
|
|
11
|
-
register<TExtra>(appOrApps: PlanetApplication<TExtra> | PlanetApplication<TExtra>[]): void;
|
|
12
|
-
registerByUrl(url: string): Observable<void>;
|
|
13
|
-
unregister(name: string): void;
|
|
14
|
-
getAppsByMatchedUrl<TExtra>(url: string): PlanetApplication<TExtra>[];
|
|
15
|
-
getAppByName(name: string): PlanetApplication<any>;
|
|
16
|
-
getAppsToPreload(excludeAppNames?: string[]): PlanetApplication<any>[];
|
|
17
|
-
getApps(): PlanetApplication<any>[];
|
|
18
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Router, UrlTree, NavigationExtras } from '@angular/router';
|
|
2
|
-
import { NgZone, Injector, ApplicationRef } from '@angular/core';
|
|
3
|
-
import { GlobalEventDispatcher } from '../global-event-dispatcher';
|
|
4
|
-
export declare class PlanetPortalApplication<TData = any> {
|
|
5
|
-
applicationRef: ApplicationRef;
|
|
6
|
-
injector: Injector;
|
|
7
|
-
router: Router;
|
|
8
|
-
ngZone: NgZone;
|
|
9
|
-
globalEventDispatcher: GlobalEventDispatcher;
|
|
10
|
-
data: TData;
|
|
11
|
-
navigateByUrl(url: string | UrlTree, extras?: NavigationExtras): Promise<boolean>;
|
|
12
|
-
run<T>(fn: (...args: any[]) => T): T;
|
|
13
|
-
tick(): void;
|
|
14
|
-
}
|
package/assets-loader.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { HttpClient } from '@angular/common/http';
|
|
3
|
-
import { PlanetApplication } from './planet.class';
|
|
4
|
-
export interface AssetsLoadResult {
|
|
5
|
-
src: string;
|
|
6
|
-
hashCode: number;
|
|
7
|
-
loaded: boolean;
|
|
8
|
-
status: string;
|
|
9
|
-
}
|
|
10
|
-
export declare class AssetsLoader {
|
|
11
|
-
private http;
|
|
12
|
-
private loadedSources;
|
|
13
|
-
constructor(http: HttpClient);
|
|
14
|
-
loadScript(src: string): Observable<AssetsLoadResult>;
|
|
15
|
-
loadStyle(src: string): Observable<AssetsLoadResult>;
|
|
16
|
-
loadScripts(sources: string[], serial?: boolean): Observable<AssetsLoadResult[]>;
|
|
17
|
-
loadStyles(sources: string[]): Observable<AssetsLoadResult[]>;
|
|
18
|
-
loadScriptsAndStyles(scripts?: string[], styles?: string[], serial?: boolean): Observable<[AssetsLoadResult[], AssetsLoadResult[]]>;
|
|
19
|
-
loadAppAssets(app: PlanetApplication): Observable<[AssetsLoadResult[], AssetsLoadResult[]]>;
|
|
20
|
-
loadManifest(url: string): Observable<{
|
|
21
|
-
[key: string]: string;
|
|
22
|
-
}>;
|
|
23
|
-
}
|