@worktile/planet 16.0.0-next.0 → 16.0.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 +4 -0
- package/component/planet-component-outlet.d.ts +1 -1
- package/{esm2020 → esm2022}/application/planet-application-loader.mjs +4 -4
- package/{esm2020 → esm2022}/application/planet-application.service.mjs +4 -4
- package/{esm2020 → esm2022}/assets-loader.mjs +4 -4
- package/{esm2020 → esm2022}/component/planet-component-loader.mjs +4 -4
- package/{esm2020 → esm2022}/component/planet-component-outlet.mjs +4 -4
- package/{esm2020 → esm2022}/empty/empty.component.mjs +4 -4
- package/{esm2020 → esm2022}/global-event-dispatcher.mjs +4 -4
- package/esm2022/module.mjs +33 -0
- package/{esm2020 → esm2022}/planet.mjs +4 -4
- package/{esm2020 → esm2022}/router/route-redirect.mjs +4 -4
- package/{fesm2020 → fesm2022}/worktile-planet.mjs +31 -31
- package/{fesm2020 → fesm2022}/worktile-planet.mjs.map +1 -1
- package/package.json +5 -11
- package/esm2020/module.mjs +0 -33
- package/fesm2015/worktile-planet.mjs +0 -2193
- package/fesm2015/worktile-planet.mjs.map +0 -1
- /package/{esm2020 → esm2022}/application/planet-application-ref.mjs +0 -0
- /package/{esm2020 → esm2022}/application/portal-application.mjs +0 -0
- /package/{esm2020 → esm2022}/component/planet-component-ref.mjs +0 -0
- /package/{esm2020 → esm2022}/component/plant-component.config.mjs +0 -0
- /package/{esm2020 → esm2022}/debug.mjs +0 -0
- /package/{esm2020 → esm2022}/global-planet.mjs +0 -0
- /package/{esm2020 → esm2022}/helpers.mjs +0 -0
- /package/{esm2020 → esm2022}/planet.class.mjs +0 -0
- /package/{esm2020 → esm2022}/public-api.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/constants.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/exec.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/index.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/proxy/patches/document.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/proxy/patches/eventListener.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/proxy/patches/index.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/proxy/patches/storage.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/proxy/patches/timer.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/proxy/proxies/common.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/proxy/proxies/document.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/proxy/proxies/window.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/proxy/proxy-sandbox.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/proxy/types.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/sandbox.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/snapshot/snapshot-sandbox.mjs +0 -0
- /package/{esm2020 → esm2022}/sandbox/types.mjs +0 -0
- /package/{esm2020 → esm2022}/worktile-planet.mjs +0 -0
|
@@ -1,2193 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, NgZone, Injectable, Inject, Optional, Component, ChangeDetectionStrategy, Injector, createComponent, reflectComponentType, EventEmitter, Directive, Input, Output, inject, NgModule } from '@angular/core';
|
|
3
|
-
import * as i3 from '@angular/router';
|
|
4
|
-
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
|
|
5
|
-
import { take, map, concatAll, switchMap, shareReplay, filter, distinctUntilChanged, catchError, tap, share, startWith, delayWhen, takeUntil } from 'rxjs/operators';
|
|
6
|
-
import { Observable, from, of, concat, forkJoin, Subject, timer } from 'rxjs';
|
|
7
|
-
import * as i1 from '@angular/common/http';
|
|
8
|
-
import { HttpClientModule } from '@angular/common/http';
|
|
9
|
-
import { DOCUMENT } from '@angular/common';
|
|
10
|
-
|
|
11
|
-
var SwitchModes;
|
|
12
|
-
(function (SwitchModes) {
|
|
13
|
-
SwitchModes["default"] = "default";
|
|
14
|
-
SwitchModes["coexist"] = "coexist";
|
|
15
|
-
})(SwitchModes || (SwitchModes = {}));
|
|
16
|
-
const PLANET_APPLICATIONS = new InjectionToken('PLANET_APPLICATIONS');
|
|
17
|
-
|
|
18
|
-
const ELEMENT_NODE_TYPE = 1;
|
|
19
|
-
function hashCode(str) {
|
|
20
|
-
let hash = 0;
|
|
21
|
-
let chr;
|
|
22
|
-
if (str.length === 0) {
|
|
23
|
-
return hash;
|
|
24
|
-
}
|
|
25
|
-
for (let i = 0; i < str.length; i++) {
|
|
26
|
-
chr = str.charCodeAt(i);
|
|
27
|
-
hash = (hash << 5) - hash + chr;
|
|
28
|
-
hash |= 0; // Convert to 32bit integer
|
|
29
|
-
}
|
|
30
|
-
return hash;
|
|
31
|
-
}
|
|
32
|
-
function getHTMLElement(selector) {
|
|
33
|
-
if (selector instanceof HTMLElement) {
|
|
34
|
-
return selector;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
return document.querySelector(selector);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function getTagNameByTemplate(template) {
|
|
41
|
-
const element = createElementByTemplate(template);
|
|
42
|
-
return element ? element.nodeName : '';
|
|
43
|
-
}
|
|
44
|
-
function createElementByTemplate(template) {
|
|
45
|
-
if (!template) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
const element = document.createRange().createContextualFragment(template).firstChild;
|
|
49
|
-
if (element && element.nodeType === ELEMENT_NODE_TYPE) {
|
|
50
|
-
return element;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
throw new Error(`invalid template '${template}'`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function coerceArray(value) {
|
|
57
|
-
return Array.isArray(value) ? value : [value];
|
|
58
|
-
}
|
|
59
|
-
function isEmpty(value) {
|
|
60
|
-
if (!value || value.length === 0) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function isFunction(value) {
|
|
68
|
-
const type = typeof value;
|
|
69
|
-
return !!value && type === 'function';
|
|
70
|
-
}
|
|
71
|
-
function isObject(val) {
|
|
72
|
-
return val && typeof val === 'object';
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Get file name from path
|
|
76
|
-
* 1. "main.js" => "main.js"
|
|
77
|
-
* 2. "assets/scripts/main.js" => "main.js"
|
|
78
|
-
* @param path path
|
|
79
|
-
*/
|
|
80
|
-
function getResourceFileName(path) {
|
|
81
|
-
const lastSlashIndex = path.lastIndexOf('/');
|
|
82
|
-
if (lastSlashIndex >= 0) {
|
|
83
|
-
return path.slice(lastSlashIndex + 1);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
return path;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Build resource path by manifest
|
|
91
|
-
* if manifest is { "main.js": "main.h2sh23abee.js"}
|
|
92
|
-
* 1. "main.js" => "main.h2sh23abee.js"
|
|
93
|
-
* 2. "assets/scripts/main.js" =>"assets/scripts/main.h2sh23abee.js"
|
|
94
|
-
* @param resourceFilePath Resource File Path
|
|
95
|
-
* @param manifestResult manifest
|
|
96
|
-
*/
|
|
97
|
-
function buildResourceFilePath(resourceFilePath, manifestResult) {
|
|
98
|
-
const fileName = getResourceFileName(resourceFilePath);
|
|
99
|
-
if (manifestResult[fileName]) {
|
|
100
|
-
return resourceFilePath.replace(fileName, manifestResult[fileName]);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
return resourceFilePath;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Get static resource full path
|
|
108
|
-
* @param app PlanetApplication
|
|
109
|
-
* @param manifestResult manifest
|
|
110
|
-
*/
|
|
111
|
-
function getScriptsAndStylesFullPaths(app, manifestResult) {
|
|
112
|
-
let scripts = app.scripts || [];
|
|
113
|
-
let styles = app.styles || [];
|
|
114
|
-
// combine resource path by manifest
|
|
115
|
-
if (manifestResult) {
|
|
116
|
-
scripts = scripts.map(script => {
|
|
117
|
-
return buildResourceFilePath(script, manifestResult);
|
|
118
|
-
});
|
|
119
|
-
styles = styles.map(style => {
|
|
120
|
-
return buildResourceFilePath(style, manifestResult);
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
if (app.resourcePathPrefix) {
|
|
124
|
-
scripts = scripts.map(script => {
|
|
125
|
-
return `${app.resourcePathPrefix}${script}`;
|
|
126
|
-
});
|
|
127
|
-
styles = styles.map(style => {
|
|
128
|
-
return `${app.resourcePathPrefix}${style}`;
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
scripts: scripts,
|
|
133
|
-
styles: styles
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const PLANET_SANDBOX_WINDOW_WHITELIST = window['___PLANET_SANDBOX_WINDOW_WHITELIST___'];
|
|
138
|
-
const PLANET_SANDBOX_DOCUMENT_WHITELIST = window['___PLANET_SANDBOX_DOCUMENT_WHITELIST___'];
|
|
139
|
-
const SANDBOX_INSTANCE = Symbol.for('PLANET_SANDBOX_INSTANCE');
|
|
140
|
-
const RAW_NODE = Symbol.for('PLANET_RAW_NODE');
|
|
141
|
-
const WINDOW_BIND_FN = Symbol.for('PLANET_WINDOW_BIND_FN');
|
|
142
|
-
const DOCUMENT_BIND_FN = Symbol.for('PLANET_DOCUMENT_BIND_FN');
|
|
143
|
-
|
|
144
|
-
const rawHasOwnProperty = Object.prototype.hasOwnProperty;
|
|
145
|
-
function hasOwnProp(obj, key) {
|
|
146
|
-
return rawHasOwnProperty.call(obj, key);
|
|
147
|
-
}
|
|
148
|
-
function isValueDescriptor(desc) {
|
|
149
|
-
if (desc === undefined) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
return 'value' in desc || 'writable' in desc;
|
|
153
|
-
}
|
|
154
|
-
function isAccessorDescriptor(desc) {
|
|
155
|
-
if (desc === undefined) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
return 'get' in desc || 'set' in desc;
|
|
159
|
-
}
|
|
160
|
-
function isNonWriteableValue(desc) {
|
|
161
|
-
return desc && desc.configurable === false && 'value' in desc && desc.writable === false;
|
|
162
|
-
}
|
|
163
|
-
function isInvalidSetAccessor(desc) {
|
|
164
|
-
if (desc && desc.configurable === false && 'set' in desc && desc.set === undefined) {
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function isInvalidGetAccessor(desc) {
|
|
172
|
-
if (desc && desc.configurable === false && 'get' in desc && desc.get === undefined) {
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function transferParams(args) {
|
|
180
|
-
args = Array.isArray(args) ? args : Array.from(args);
|
|
181
|
-
return args.map(arg => {
|
|
182
|
-
return arg[RAW_NODE] ? arg[RAW_NODE] : arg;
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
const buildInProps = ['length', 'caller', 'callee', 'arguments', 'prototype', Symbol.hasInstance];
|
|
186
|
-
function transferProps(o, n) {
|
|
187
|
-
for (const key of Reflect.ownKeys(o)) {
|
|
188
|
-
if (buildInProps.includes(key)) {
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
const desc = Object.getOwnPropertyDescriptor(n, key);
|
|
192
|
-
if (desc && desc.writable) {
|
|
193
|
-
n[key] = o[key];
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function bind(fn, context) {
|
|
198
|
-
const fNOP = function () { };
|
|
199
|
-
function bound() {
|
|
200
|
-
const args = transferParams(arguments);
|
|
201
|
-
if (this instanceof bound) {
|
|
202
|
-
const obj = new fn(...args);
|
|
203
|
-
Object.setPrototypeOf(obj, bound.prototype);
|
|
204
|
-
return obj;
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
return fn.apply(context, args);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
bound.$native = fn;
|
|
211
|
-
transferProps(fn, bound);
|
|
212
|
-
if (fn.prototype) {
|
|
213
|
-
fNOP.prototype = fn.prototype;
|
|
214
|
-
}
|
|
215
|
-
bound.prototype = new fNOP();
|
|
216
|
-
if (Symbol.hasInstance) {
|
|
217
|
-
Object.defineProperty(bound, Symbol.hasInstance, {
|
|
218
|
-
configurable: true,
|
|
219
|
-
value(instance) {
|
|
220
|
-
const op = fn.prototype;
|
|
221
|
-
return isObject(op) || typeof op === 'function' ? instance instanceof fn : false;
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
return bound;
|
|
226
|
-
}
|
|
227
|
-
function createFakeObject(target, writableKeys) {
|
|
228
|
-
const fakeObject = {};
|
|
229
|
-
const propertyMap = {};
|
|
230
|
-
const storageBox = Object.create(null);
|
|
231
|
-
const propertyNames = Object.getOwnPropertyNames(target);
|
|
232
|
-
const def = (p) => {
|
|
233
|
-
const descriptor = Object.getOwnPropertyDescriptor(target, p);
|
|
234
|
-
if (descriptor === null || descriptor === void 0 ? void 0 : descriptor.configurable) {
|
|
235
|
-
const hasGetter = hasOwnProp(descriptor, 'get');
|
|
236
|
-
const hasSetter = hasOwnProp(descriptor, 'set');
|
|
237
|
-
const canWritable = writableKeys && writableKeys.length > 0 && writableKeys.includes(p);
|
|
238
|
-
if (hasGetter) {
|
|
239
|
-
descriptor.get = () => (hasOwnProp(storageBox, p) ? storageBox[p] : target[p]);
|
|
240
|
-
}
|
|
241
|
-
if (hasSetter) {
|
|
242
|
-
descriptor.set = val => {
|
|
243
|
-
storageBox[p] = val;
|
|
244
|
-
return true;
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
if (canWritable) {
|
|
248
|
-
if (descriptor.writable === false) {
|
|
249
|
-
descriptor.writable = true;
|
|
250
|
-
}
|
|
251
|
-
else if (hasGetter) {
|
|
252
|
-
descriptor.set = val => {
|
|
253
|
-
storageBox[p] = val;
|
|
254
|
-
return true;
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
Object.defineProperty(fakeObject, p, Object.freeze(descriptor));
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
propertyNames.forEach(p => {
|
|
262
|
-
propertyMap[p] = true;
|
|
263
|
-
def(p);
|
|
264
|
-
});
|
|
265
|
-
// 再次循环是为了处理原型链中的属性
|
|
266
|
-
for (const prop in target) {
|
|
267
|
-
if (!propertyMap[prop]) {
|
|
268
|
-
def(prop);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
return fakeObject;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const esGlobalFunctions = ('eval,isFinite,isNaN,parseFloat,parseInt,' +
|
|
275
|
-
// URL handling functions
|
|
276
|
-
'decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
|
|
277
|
-
// Constructor properties of the global object
|
|
278
|
-
'Array,ArrayBuffer,BigInt,BigInt64Array,BigUint64Array,Boolean,DataView,Date,Error,EvalError,' +
|
|
279
|
-
'FinalizationRegistry,Float32Array,Float64Array,Function,Int8Array,Int16Array,Int32Array,Map,Number,' +
|
|
280
|
-
'Object,Promise,Proxy,RangeError,ReferenceError,RegExp,Set,SharedArrayBuffer,String,Symbol,SyntaxError,' +
|
|
281
|
-
'TypeError,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,URIError,WeakMap,WeakRef,WeakSet,' +
|
|
282
|
-
// Other Properties of the Global Object
|
|
283
|
-
'Atomics,JSON,Math,Reflect').split(',');
|
|
284
|
-
const whitelistVariables = PLANET_SANDBOX_WINDOW_WHITELIST || [];
|
|
285
|
-
function isConstructor(fn) {
|
|
286
|
-
const fp = fn.prototype;
|
|
287
|
-
const hasConstructor = fp && fp.constructor === fn && Object.getOwnPropertyNames(fp).length > 1;
|
|
288
|
-
const functionStr = !hasConstructor && fn.toString();
|
|
289
|
-
return hasConstructor || /^function\s+[A-Z]/.test(functionStr) || /^class\b/.test(functionStr);
|
|
290
|
-
}
|
|
291
|
-
const unscopables = {
|
|
292
|
-
undefined: true,
|
|
293
|
-
Array: true,
|
|
294
|
-
Object: true,
|
|
295
|
-
String: true,
|
|
296
|
-
Boolean: true,
|
|
297
|
-
Math: true,
|
|
298
|
-
Number: true,
|
|
299
|
-
Symbol: true,
|
|
300
|
-
parseFloat: true,
|
|
301
|
-
Float32Array: true
|
|
302
|
-
};
|
|
303
|
-
class ProxyWindow {
|
|
304
|
-
constructor(sandbox) {
|
|
305
|
-
this.sandbox = sandbox;
|
|
306
|
-
this.definedVariables = new Set();
|
|
307
|
-
}
|
|
308
|
-
createGetter() {
|
|
309
|
-
return (target, key, receiver) => {
|
|
310
|
-
if (key === Symbol.unscopables) {
|
|
311
|
-
return unscopables;
|
|
312
|
-
}
|
|
313
|
-
if (key === SANDBOX_INSTANCE) {
|
|
314
|
-
return this.sandbox;
|
|
315
|
-
}
|
|
316
|
-
let value = null;
|
|
317
|
-
if (whitelistVariables.includes(key)) {
|
|
318
|
-
return Reflect.get(window, key);
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
value = hasOwnProp(target, key) ? Reflect.get(target, key, receiver) : Reflect.get(window, key);
|
|
322
|
-
}
|
|
323
|
-
if (isFunction(value)) {
|
|
324
|
-
if (esGlobalFunctions.includes(key) ||
|
|
325
|
-
whitelistVariables.includes(key) ||
|
|
326
|
-
this.sandbox.rewriteVariables.includes(key) ||
|
|
327
|
-
this.definedVariables.has(key) ||
|
|
328
|
-
isConstructor(value)) {
|
|
329
|
-
return value;
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
const newValue = hasOwnProp(value, WINDOW_BIND_FN) ? value[WINDOW_BIND_FN] : bind(value, window);
|
|
333
|
-
const desc = Object.getOwnPropertyDescriptor(target, key);
|
|
334
|
-
if (isNonWriteableValue(desc)) {
|
|
335
|
-
return value;
|
|
336
|
-
}
|
|
337
|
-
if (isInvalidGetAccessor(desc)) {
|
|
338
|
-
return undefined;
|
|
339
|
-
}
|
|
340
|
-
value[WINDOW_BIND_FN] = newValue;
|
|
341
|
-
return newValue;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
return value;
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
createSetter() {
|
|
350
|
-
return (target, key, value, receiver) => {
|
|
351
|
-
const desc = Object.getOwnPropertyDescriptor(whitelistVariables.includes(key) ? window : receiver ? receiver : target, key);
|
|
352
|
-
if (desc && isNonWriteableValue(desc)) {
|
|
353
|
-
if (!Object.is(value, desc.value)) {
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
return true;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (isInvalidSetAccessor(desc)) {
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
if (whitelistVariables.includes(key)) {
|
|
364
|
-
return Reflect.set(window, key, value);
|
|
365
|
-
}
|
|
366
|
-
else {
|
|
367
|
-
const success = Reflect.set(target, key, value, receiver);
|
|
368
|
-
if (success) {
|
|
369
|
-
if (this.sandbox.running) {
|
|
370
|
-
this.definedVariables.add(key);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return success;
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
createDefineProperty() {
|
|
378
|
-
return (target, p, descriptor) => {
|
|
379
|
-
if (whitelistVariables.includes(p)) {
|
|
380
|
-
return Reflect.defineProperty(window, p, descriptor);
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
const success = Reflect.defineProperty(target, p, descriptor);
|
|
384
|
-
if (this.sandbox.running && success) {
|
|
385
|
-
this.definedVariables.add(p);
|
|
386
|
-
}
|
|
387
|
-
return success;
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
createDeleteProperty() {
|
|
392
|
-
return (target, p) => {
|
|
393
|
-
if (hasOwnProp(target, p)) {
|
|
394
|
-
delete target[p];
|
|
395
|
-
if (this.sandbox.running && this.definedVariables.has(p)) {
|
|
396
|
-
this.definedVariables.delete(p);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return true;
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
createHas() {
|
|
403
|
-
return (_target, key) => {
|
|
404
|
-
return !whitelistVariables.includes(key);
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
create() {
|
|
408
|
-
const fakeWindow = createFakeObject(window, this.sandbox.rewriteVariables);
|
|
409
|
-
const baseHandlers = {
|
|
410
|
-
get: this.createGetter(),
|
|
411
|
-
set: this.createSetter(),
|
|
412
|
-
defineProperty: this.createDefineProperty(),
|
|
413
|
-
deleteProperty: this.createDeleteProperty()
|
|
414
|
-
};
|
|
415
|
-
const proxy = new Proxy(fakeWindow, Object.assign(Object.assign({}, baseHandlers), { has: this.createHas() }));
|
|
416
|
-
const subProxy = new Proxy(fakeWindow, baseHandlers);
|
|
417
|
-
proxy.self = subProxy;
|
|
418
|
-
proxy.window = subProxy;
|
|
419
|
-
proxy.globalThis = subProxy;
|
|
420
|
-
proxy.top = window.top === window ? subProxy : window.top;
|
|
421
|
-
proxy.parent = window.parent === window ? subProxy : window.top;
|
|
422
|
-
return proxy;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
function eventListenerPatch(sandbox) {
|
|
427
|
-
const rawAddEventListener = window.addEventListener;
|
|
428
|
-
const rawRemoveEventListener = window.removeEventListener;
|
|
429
|
-
const listenerSubscriptions = new Map();
|
|
430
|
-
function addEventListener(type, listener, options) {
|
|
431
|
-
const observable = new Observable(() => {
|
|
432
|
-
rawAddEventListener.call(this, type, listener, options);
|
|
433
|
-
return () => {
|
|
434
|
-
rawRemoveEventListener.call(this, type, listener, options);
|
|
435
|
-
};
|
|
436
|
-
});
|
|
437
|
-
const subscription = observable.subscribe(() => { });
|
|
438
|
-
listenerSubscriptions.set(listener, subscription);
|
|
439
|
-
}
|
|
440
|
-
function removeEventListener(type, listener) {
|
|
441
|
-
const subscription = listenerSubscriptions.get(listener);
|
|
442
|
-
if (subscription) {
|
|
443
|
-
subscription.unsubscribe();
|
|
444
|
-
listenerSubscriptions.delete(listener);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
return {
|
|
448
|
-
rewrite: {
|
|
449
|
-
addEventListener: addEventListener.bind(window),
|
|
450
|
-
removeEventListener: removeEventListener.bind(window)
|
|
451
|
-
},
|
|
452
|
-
init() {
|
|
453
|
-
const fakeDocument = sandbox.global.document;
|
|
454
|
-
if (fakeDocument) {
|
|
455
|
-
fakeDocument.addEventListener = addEventListener.bind(document);
|
|
456
|
-
fakeDocument.removeEventListener = removeEventListener.bind(document);
|
|
457
|
-
}
|
|
458
|
-
},
|
|
459
|
-
destroy() {
|
|
460
|
-
listenerSubscriptions.forEach(subscription => subscription.unsubscribe());
|
|
461
|
-
listenerSubscriptions.clear();
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
const rawDocument = Document;
|
|
467
|
-
const whitelist = ['cookie', 'title', 'location', ...(PLANET_SANDBOX_DOCUMENT_WHITELIST || [])];
|
|
468
|
-
class ProxyDocument {
|
|
469
|
-
constructor() { }
|
|
470
|
-
createGetter() {
|
|
471
|
-
return (target, p, receiver) => {
|
|
472
|
-
const value = hasOwnProp(target, p) ? Reflect.get(target, p, receiver) : Reflect.get(document, p);
|
|
473
|
-
if (p === 'activeElement') {
|
|
474
|
-
return Reflect.get(document, p);
|
|
475
|
-
}
|
|
476
|
-
// TODO: 处理动态节点
|
|
477
|
-
// if (p === 'createElement') {
|
|
478
|
-
// return function(tagName: string, options: ElementCreationOptions) {
|
|
479
|
-
// const created = value.call(document, tagName, options);
|
|
480
|
-
// if (isObject(created)) {
|
|
481
|
-
// created[SANDBOX_INSTANCE] = sandbox;
|
|
482
|
-
// }
|
|
483
|
-
// return created;
|
|
484
|
-
// };
|
|
485
|
-
// }
|
|
486
|
-
if (isFunction(value)) {
|
|
487
|
-
let newValue = hasOwnProp(value, DOCUMENT_BIND_FN) ? value[DOCUMENT_BIND_FN] : null;
|
|
488
|
-
if (!newValue) {
|
|
489
|
-
newValue = bind(value, document);
|
|
490
|
-
}
|
|
491
|
-
const desc = Object.getOwnPropertyDescriptor(target, p);
|
|
492
|
-
if (desc && isNonWriteableValue(desc)) {
|
|
493
|
-
if (!Object.is(newValue, desc.value)) {
|
|
494
|
-
return value;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
if (isInvalidGetAccessor(desc)) {
|
|
498
|
-
return undefined;
|
|
499
|
-
}
|
|
500
|
-
value[DOCUMENT_BIND_FN] = newValue;
|
|
501
|
-
return newValue;
|
|
502
|
-
}
|
|
503
|
-
return value;
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
createSetter() {
|
|
507
|
-
return (target, p, value, receiver) => {
|
|
508
|
-
const desc = Object.getOwnPropertyDescriptor(whitelist.includes(p) ? document : receiver || target, p);
|
|
509
|
-
if (desc && isNonWriteableValue(desc)) {
|
|
510
|
-
if (Object.is(value, desc.value)) {
|
|
511
|
-
return true;
|
|
512
|
-
}
|
|
513
|
-
else {
|
|
514
|
-
return false;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
if (isInvalidSetAccessor(desc)) {
|
|
518
|
-
return false;
|
|
519
|
-
}
|
|
520
|
-
return whitelist.includes(p) ? Reflect.set(document, p, value) : Reflect.set(target, p, value, receiver);
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
createDefineProperty() {
|
|
524
|
-
return (target, p, descriptor) => {
|
|
525
|
-
return whitelist.includes(p)
|
|
526
|
-
? Reflect.defineProperty(document, p, descriptor)
|
|
527
|
-
: Reflect.defineProperty(target, p, descriptor);
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
create() {
|
|
531
|
-
let proxyDocument = null;
|
|
532
|
-
const fakeDocument = createFakeObject(document);
|
|
533
|
-
const getter = this.createGetter();
|
|
534
|
-
const fakeDocumentProto = new Proxy(fakeDocument, {
|
|
535
|
-
get: (...args) => {
|
|
536
|
-
return getter(...args);
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
const fakeDocumentCtor = function Document() {
|
|
540
|
-
if (!(this instanceof fakeDocumentCtor)) {
|
|
541
|
-
throw new TypeError(`Failed to construct 'Document': Please use the 'new' operator.`);
|
|
542
|
-
}
|
|
543
|
-
const docInstance = new rawDocument();
|
|
544
|
-
Object.setPrototypeOf(docInstance, fakeDocument);
|
|
545
|
-
return docInstance;
|
|
546
|
-
};
|
|
547
|
-
fakeDocumentCtor.prototype = fakeDocumentProto;
|
|
548
|
-
fakeDocumentCtor.prototype.constructor = fakeDocumentCtor;
|
|
549
|
-
if (Symbol.hasInstance) {
|
|
550
|
-
Object.defineProperty(fakeDocumentCtor, Symbol.hasInstance, {
|
|
551
|
-
configurable: true,
|
|
552
|
-
value(value) {
|
|
553
|
-
let proto = value;
|
|
554
|
-
if (proto === document) {
|
|
555
|
-
return true;
|
|
556
|
-
}
|
|
557
|
-
while ((proto = Object.getPrototypeOf(proto))) {
|
|
558
|
-
if (proto === fakeDocumentProto) {
|
|
559
|
-
return true;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
const cloned = function () { };
|
|
563
|
-
cloned.prototype = fakeDocument;
|
|
564
|
-
return value instanceof cloned;
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
proxyDocument = new Proxy(Object.create(fakeDocumentProto, {
|
|
569
|
-
currentScript: {
|
|
570
|
-
value: null,
|
|
571
|
-
writable: true
|
|
572
|
-
},
|
|
573
|
-
[RAW_NODE]: {
|
|
574
|
-
writable: false,
|
|
575
|
-
configurable: false,
|
|
576
|
-
value: document
|
|
577
|
-
}
|
|
578
|
-
}), {
|
|
579
|
-
set: this.createSetter(),
|
|
580
|
-
defineProperty: this.createDefineProperty()
|
|
581
|
-
});
|
|
582
|
-
return {
|
|
583
|
-
document: proxyDocument,
|
|
584
|
-
Document: fakeDocumentCtor
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
function documentPatch() {
|
|
590
|
-
const proxyDocument = new ProxyDocument();
|
|
591
|
-
const { document, Document } = proxyDocument.create();
|
|
592
|
-
return {
|
|
593
|
-
rewrite: {
|
|
594
|
-
document,
|
|
595
|
-
Document
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
const rawSetTimeout = window.setTimeout;
|
|
601
|
-
const rawClearTimeout = window.clearTimeout;
|
|
602
|
-
const rawSetInterval = window.setInterval;
|
|
603
|
-
const rawClearInterval = window.clearInterval;
|
|
604
|
-
function timerPatch() {
|
|
605
|
-
const timeout = new Set();
|
|
606
|
-
const interval = new Set();
|
|
607
|
-
function rewriteSetTimeout(handler, ms, ...args) {
|
|
608
|
-
const timeoutId = rawSetTimeout(handler, ms, ...args);
|
|
609
|
-
timeout.add(timeoutId);
|
|
610
|
-
return timeoutId;
|
|
611
|
-
}
|
|
612
|
-
function rewriteClearTimeout(timeoutId) {
|
|
613
|
-
timeout.delete(timeoutId);
|
|
614
|
-
rawClearTimeout(timeoutId);
|
|
615
|
-
}
|
|
616
|
-
function rewriteSetInterval(handler, ms, ...args) {
|
|
617
|
-
const intervalId = rawSetInterval(handler, ms, ...args);
|
|
618
|
-
interval.add(intervalId);
|
|
619
|
-
return intervalId;
|
|
620
|
-
}
|
|
621
|
-
function rewriteClearInterval(intervalId) {
|
|
622
|
-
interval.delete(intervalId);
|
|
623
|
-
rawClearInterval(intervalId);
|
|
624
|
-
}
|
|
625
|
-
return {
|
|
626
|
-
rewrite: {
|
|
627
|
-
setTimeout: rewriteSetTimeout,
|
|
628
|
-
clearTimeout: rewriteClearTimeout,
|
|
629
|
-
setInterval: rewriteSetInterval,
|
|
630
|
-
clearInterval: rewriteClearInterval
|
|
631
|
-
},
|
|
632
|
-
destroy: () => {
|
|
633
|
-
timeout.forEach(timeoutId => {
|
|
634
|
-
rawClearTimeout(timeoutId);
|
|
635
|
-
});
|
|
636
|
-
interval.forEach(intervalId => {
|
|
637
|
-
rawClearInterval(intervalId);
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
const PLANET_STORAGE_PREFIX = '__planet-storage-';
|
|
644
|
-
class RewriteStorage {
|
|
645
|
-
constructor(app, rawStorage) {
|
|
646
|
-
this.rawStorage = rawStorage;
|
|
647
|
-
this.prefix = `${PLANET_STORAGE_PREFIX}${app}__:`;
|
|
648
|
-
}
|
|
649
|
-
get length() {
|
|
650
|
-
return this.getKeys().length;
|
|
651
|
-
}
|
|
652
|
-
getKeys() {
|
|
653
|
-
return Object.keys(this.rawStorage).filter(key => key.startsWith(this.prefix));
|
|
654
|
-
}
|
|
655
|
-
key(n) {
|
|
656
|
-
const key = this.getKeys()[n];
|
|
657
|
-
return key ? key.substring(this.prefix.length) : null;
|
|
658
|
-
}
|
|
659
|
-
getItem(key) {
|
|
660
|
-
return this.rawStorage.getItem(`${this.prefix + key}`);
|
|
661
|
-
}
|
|
662
|
-
setItem(key, value) {
|
|
663
|
-
this.rawStorage.setItem(`${this.prefix + key}`, value);
|
|
664
|
-
}
|
|
665
|
-
removeItem(key) {
|
|
666
|
-
this.rawStorage.removeItem(`${this.prefix + key}`);
|
|
667
|
-
}
|
|
668
|
-
clear() {
|
|
669
|
-
this.getKeys().forEach(key => {
|
|
670
|
-
this.rawStorage.removeItem(key);
|
|
671
|
-
});
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
function storagePatch(sandbox) {
|
|
675
|
-
return {
|
|
676
|
-
rewrite: {
|
|
677
|
-
localStorage: new RewriteStorage(sandbox.app, localStorage),
|
|
678
|
-
sessionStorage: new RewriteStorage(sandbox.app, sessionStorage)
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
const sandboxPatches = [documentPatch, eventListenerPatch, timerPatch, storagePatch];
|
|
684
|
-
function getSandboxPatchHandlers(sandbox) {
|
|
685
|
-
return sandboxPatches.map(patch => {
|
|
686
|
-
return patch(sandbox);
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
function execScript(code, url, global, strictGlobal) {
|
|
691
|
-
const sourceUrl = '//# sourceURL='.concat(url, '\n');
|
|
692
|
-
const window = (0, eval)('window');
|
|
693
|
-
window.tempGlobal = global;
|
|
694
|
-
code = strictGlobal
|
|
695
|
-
? ';(function(window, self, globalThis){with(window){;'
|
|
696
|
-
.concat(code, '\n')
|
|
697
|
-
.concat(sourceUrl, '}}).bind(window.tempGlobal)(window.tempGlobal, window.tempGlobal, window.tempGlobal);')
|
|
698
|
-
: ';(function(window, self, globalThis){;'
|
|
699
|
-
.concat(code, '\n')
|
|
700
|
-
.concat(sourceUrl, '}).bind(window.tempGlobal)(window.tempGlobal, window.tempGlobal, window.tempGlobal);');
|
|
701
|
-
(0, eval)(code);
|
|
702
|
-
delete window.tempGlobal;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
class Sandbox {
|
|
706
|
-
execScript(code, url = '') {
|
|
707
|
-
execScript(code, url, this.global, !!this.options.strictGlobal);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
class ProxySandbox extends Sandbox {
|
|
712
|
-
constructor(app, options) {
|
|
713
|
-
super();
|
|
714
|
-
this.app = app;
|
|
715
|
-
this.options = options;
|
|
716
|
-
this.running = false;
|
|
717
|
-
this.patchHandlers = [];
|
|
718
|
-
this.patchHandlers = getSandboxPatchHandlers(this);
|
|
719
|
-
this.start();
|
|
720
|
-
}
|
|
721
|
-
start() {
|
|
722
|
-
this.running = true;
|
|
723
|
-
this.rewriteVariables = this.getPatchRewriteVariables();
|
|
724
|
-
const proxyWindow = new ProxyWindow(this);
|
|
725
|
-
this.global = proxyWindow.create();
|
|
726
|
-
this.execPatchHandlers();
|
|
727
|
-
}
|
|
728
|
-
destroy() {
|
|
729
|
-
this.running = false;
|
|
730
|
-
this.patchHandlers.forEach(handler => {
|
|
731
|
-
if (handler.destroy) {
|
|
732
|
-
handler.destroy();
|
|
733
|
-
}
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
getPatchRewriteVariables() {
|
|
737
|
-
return this.patchHandlers.reduce((pre, cur) => {
|
|
738
|
-
return [...pre, ...(cur.rewrite ? Object.keys(cur.rewrite) : [])];
|
|
739
|
-
}, []);
|
|
740
|
-
}
|
|
741
|
-
execPatchHandlers() {
|
|
742
|
-
this.patchHandlers.forEach(handler => {
|
|
743
|
-
if (handler.rewrite) {
|
|
744
|
-
for (const key in handler.rewrite) {
|
|
745
|
-
if (handler.rewrite[key]) {
|
|
746
|
-
this.global[key] = handler.rewrite[key];
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
if (handler.init) {
|
|
751
|
-
handler === null || handler === void 0 ? void 0 : handler.init();
|
|
752
|
-
}
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
class SnapshotSandbox extends Sandbox {
|
|
758
|
-
constructor(app, options) {
|
|
759
|
-
super();
|
|
760
|
-
this.app = app;
|
|
761
|
-
this.options = options;
|
|
762
|
-
this.start();
|
|
763
|
-
}
|
|
764
|
-
start() { }
|
|
765
|
-
destroy() { }
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
const defaultOptions = {
|
|
769
|
-
strictGlobal: false
|
|
770
|
-
};
|
|
771
|
-
function createSandbox(app, options) {
|
|
772
|
-
options = Object.assign({}, defaultOptions, options || {});
|
|
773
|
-
if (window.Proxy) {
|
|
774
|
-
return new ProxySandbox(app, options);
|
|
775
|
-
}
|
|
776
|
-
else {
|
|
777
|
-
return new SnapshotSandbox(app, options);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
function getSandboxInstance() {
|
|
781
|
-
return window[SANDBOX_INSTANCE];
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
class PlanetApplicationRef {
|
|
785
|
-
get selector() {
|
|
786
|
-
return this.innerSelector;
|
|
787
|
-
}
|
|
788
|
-
get bootstrapped() {
|
|
789
|
-
return !!this.appModuleRef;
|
|
790
|
-
}
|
|
791
|
-
get ngZone() {
|
|
792
|
-
var _a;
|
|
793
|
-
return (_a = this.appModuleRef) === null || _a === void 0 ? void 0 : _a.injector.get(NgZone);
|
|
794
|
-
}
|
|
795
|
-
get sandbox() {
|
|
796
|
-
return getSandboxInstance();
|
|
797
|
-
}
|
|
798
|
-
constructor(name, options) {
|
|
799
|
-
this.name = name;
|
|
800
|
-
if (options) {
|
|
801
|
-
this.template = options.template;
|
|
802
|
-
this.innerSelector = this.template ? getTagNameByTemplate(this.template) : '';
|
|
803
|
-
this.appModuleBootstrap = options.bootstrap;
|
|
804
|
-
}
|
|
805
|
-
// This is a hack, since NgZone doesn't allow you to configure the property that identifies your zone.
|
|
806
|
-
// See https://github.com/PlaceMe-SAS/single-spa-angular-cli/issues/33,
|
|
807
|
-
NgZone.isInAngularZone = () => {
|
|
808
|
-
// @ts-ignore
|
|
809
|
-
return window.Zone.current._properties[`ngx-planet-${name}`] === true;
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
// 子应用路由变化后同步修改 portal 的 Route
|
|
813
|
-
syncPortalRouteWhenNavigationEnd() {
|
|
814
|
-
var _a;
|
|
815
|
-
const router = (_a = this.appModuleRef) === null || _a === void 0 ? void 0 : _a.injector.get(Router);
|
|
816
|
-
if (router) {
|
|
817
|
-
router.events.subscribe(event => {
|
|
818
|
-
var _a;
|
|
819
|
-
if (event instanceof NavigationEnd) {
|
|
820
|
-
(_a = this.ngZone) === null || _a === void 0 ? void 0 : _a.onStable.asObservable().pipe(take(1)).subscribe(() => {
|
|
821
|
-
this.portalApp.router.navigateByUrl(event.url);
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
});
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
bootstrap(app) {
|
|
828
|
-
if (!this.appModuleBootstrap) {
|
|
829
|
-
throw new Error(`app(${this.name}) is not defined`);
|
|
830
|
-
}
|
|
831
|
-
this.portalApp = app;
|
|
832
|
-
return from(this.appModuleBootstrap(app).then(appModuleRef => {
|
|
833
|
-
this.appModuleRef = appModuleRef;
|
|
834
|
-
this.appModuleRef.instance.appName = this.name;
|
|
835
|
-
this.syncPortalRouteWhenNavigationEnd();
|
|
836
|
-
return this;
|
|
837
|
-
}));
|
|
838
|
-
}
|
|
839
|
-
getRouter() {
|
|
840
|
-
var _a;
|
|
841
|
-
return (_a = this.appModuleRef) === null || _a === void 0 ? void 0 : _a.injector.get(Router);
|
|
842
|
-
}
|
|
843
|
-
getCurrentRouterStateUrl() {
|
|
844
|
-
var _a;
|
|
845
|
-
return (_a = this.getRouter()) === null || _a === void 0 ? void 0 : _a.routerState.snapshot.url;
|
|
846
|
-
}
|
|
847
|
-
navigateByUrl(url) {
|
|
848
|
-
var _a;
|
|
849
|
-
const router = this.getRouter();
|
|
850
|
-
(_a = this.ngZone) === null || _a === void 0 ? void 0 : _a.run(() => {
|
|
851
|
-
router === null || router === void 0 ? void 0 : router.navigateByUrl(url);
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
getComponentFactory() {
|
|
855
|
-
return this.componentFactory;
|
|
856
|
-
}
|
|
857
|
-
registerComponentFactory(componentFactory) {
|
|
858
|
-
this.componentFactory = componentFactory;
|
|
859
|
-
}
|
|
860
|
-
destroy() {
|
|
861
|
-
if (this.appModuleRef) {
|
|
862
|
-
const router = this.appModuleRef.injector.get(Router);
|
|
863
|
-
if (router) {
|
|
864
|
-
router.dispose();
|
|
865
|
-
}
|
|
866
|
-
if (this.sandbox) {
|
|
867
|
-
this.sandbox.destroy();
|
|
868
|
-
}
|
|
869
|
-
this.appModuleRef.destroy();
|
|
870
|
-
this.appModuleRef = undefined;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
const globalPlanet = (window.planet = window.planet || {
|
|
876
|
-
apps: {}
|
|
877
|
-
});
|
|
878
|
-
function defineApplication(name, options) {
|
|
879
|
-
if (globalPlanet.apps[name]) {
|
|
880
|
-
throw new Error(`${name} application has exist.`);
|
|
881
|
-
}
|
|
882
|
-
if (isFunction(options)) {
|
|
883
|
-
options = {
|
|
884
|
-
template: '',
|
|
885
|
-
bootstrap: options
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
const appRef = new PlanetApplicationRef(name, options);
|
|
889
|
-
globalPlanet.apps[name] = appRef;
|
|
890
|
-
}
|
|
891
|
-
function getPlanetApplicationRef(appName) {
|
|
892
|
-
if (globalPlanet && globalPlanet.apps && globalPlanet.apps[appName]) {
|
|
893
|
-
return globalPlanet.apps[appName];
|
|
894
|
-
}
|
|
895
|
-
else {
|
|
896
|
-
return null;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
function setPortalApplicationData(data) {
|
|
900
|
-
if (globalPlanet.portalApplication) {
|
|
901
|
-
globalPlanet.portalApplication.data = data;
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
function getPortalApplicationData() {
|
|
905
|
-
var _a;
|
|
906
|
-
return (_a = globalPlanet.portalApplication) === null || _a === void 0 ? void 0 : _a.data;
|
|
907
|
-
}
|
|
908
|
-
function setApplicationLoader(loader) {
|
|
909
|
-
globalPlanet.applicationLoader = loader;
|
|
910
|
-
}
|
|
911
|
-
function getApplicationLoader() {
|
|
912
|
-
return globalPlanet.applicationLoader;
|
|
913
|
-
}
|
|
914
|
-
function setApplicationService(service) {
|
|
915
|
-
globalPlanet.applicationService = service;
|
|
916
|
-
}
|
|
917
|
-
function getApplicationService() {
|
|
918
|
-
return globalPlanet.applicationService;
|
|
919
|
-
}
|
|
920
|
-
function clearGlobalPlanet() {
|
|
921
|
-
window.planet.apps = {};
|
|
922
|
-
window.planet.portalApplication = null;
|
|
923
|
-
window.planet.applicationLoader = null;
|
|
924
|
-
window.planet.applicationService = null;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
class AssetsLoader {
|
|
928
|
-
constructor(http) {
|
|
929
|
-
this.http = http;
|
|
930
|
-
this.loadedSources = [];
|
|
931
|
-
}
|
|
932
|
-
loadScript(src) {
|
|
933
|
-
const id = hashCode(src);
|
|
934
|
-
if (this.loadedSources.includes(id)) {
|
|
935
|
-
return of({
|
|
936
|
-
src: src,
|
|
937
|
-
hashCode: id,
|
|
938
|
-
loaded: true,
|
|
939
|
-
status: 'Loaded'
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
|
-
return new Observable((observer) => {
|
|
943
|
-
const script = document.createElement('script');
|
|
944
|
-
script.type = 'text/javascript';
|
|
945
|
-
script.src = src;
|
|
946
|
-
script.async = true;
|
|
947
|
-
if (script['readyState']) {
|
|
948
|
-
// IE
|
|
949
|
-
script['onreadystatechange'] = () => {
|
|
950
|
-
if (script['readyState'] === 'loaded' || script['readyState'] === 'complete') {
|
|
951
|
-
script['onreadystatechange'] = null;
|
|
952
|
-
observer.next({
|
|
953
|
-
src: src,
|
|
954
|
-
hashCode: id,
|
|
955
|
-
loaded: true,
|
|
956
|
-
status: 'Loaded'
|
|
957
|
-
});
|
|
958
|
-
observer.complete();
|
|
959
|
-
this.loadedSources.push(id);
|
|
960
|
-
}
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
else {
|
|
964
|
-
// Others
|
|
965
|
-
script.onload = () => {
|
|
966
|
-
observer.next({
|
|
967
|
-
src: src,
|
|
968
|
-
hashCode: id,
|
|
969
|
-
loaded: true,
|
|
970
|
-
status: 'Loaded'
|
|
971
|
-
});
|
|
972
|
-
observer.complete();
|
|
973
|
-
this.loadedSources.push(id);
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
script.onerror = error => {
|
|
977
|
-
observer.error({
|
|
978
|
-
src: src,
|
|
979
|
-
hashCode: id,
|
|
980
|
-
loaded: false,
|
|
981
|
-
status: 'Error',
|
|
982
|
-
error: error
|
|
983
|
-
});
|
|
984
|
-
observer.complete();
|
|
985
|
-
};
|
|
986
|
-
document.body.appendChild(script);
|
|
987
|
-
});
|
|
988
|
-
}
|
|
989
|
-
loadScriptWithSandbox(app, src) {
|
|
990
|
-
const id = hashCode(src);
|
|
991
|
-
if (this.loadedSources.includes(id)) {
|
|
992
|
-
return of({
|
|
993
|
-
src: src,
|
|
994
|
-
hashCode: id,
|
|
995
|
-
loaded: true,
|
|
996
|
-
status: 'Loaded'
|
|
997
|
-
});
|
|
998
|
-
}
|
|
999
|
-
return new Observable((observer) => {
|
|
1000
|
-
this.http.get(src, { responseType: 'text' }).subscribe((code) => {
|
|
1001
|
-
this.loadedSources.push(id);
|
|
1002
|
-
const sandbox = createSandbox(app);
|
|
1003
|
-
sandbox.execScript(code, src);
|
|
1004
|
-
observer.next({
|
|
1005
|
-
src: src,
|
|
1006
|
-
hashCode: id,
|
|
1007
|
-
loaded: true,
|
|
1008
|
-
status: 'Loaded'
|
|
1009
|
-
});
|
|
1010
|
-
observer.complete();
|
|
1011
|
-
}, error => {
|
|
1012
|
-
observer.error({
|
|
1013
|
-
src: src,
|
|
1014
|
-
hashCode: id,
|
|
1015
|
-
loaded: false,
|
|
1016
|
-
status: 'Error',
|
|
1017
|
-
error: error
|
|
1018
|
-
});
|
|
1019
|
-
observer.complete();
|
|
1020
|
-
});
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
loadStyle(src) {
|
|
1024
|
-
const id = hashCode(src);
|
|
1025
|
-
if (this.loadedSources.includes(id)) {
|
|
1026
|
-
return of({
|
|
1027
|
-
src: src,
|
|
1028
|
-
hashCode: id,
|
|
1029
|
-
loaded: true,
|
|
1030
|
-
status: 'Loaded'
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
return new Observable((observer) => {
|
|
1034
|
-
const head = document.getElementsByTagName('head')[0];
|
|
1035
|
-
const link = document.createElement('link');
|
|
1036
|
-
link.rel = 'stylesheet';
|
|
1037
|
-
link.type = 'text/css';
|
|
1038
|
-
link.href = src;
|
|
1039
|
-
link.media = 'all';
|
|
1040
|
-
link.onload = () => {
|
|
1041
|
-
observer.next({
|
|
1042
|
-
src: src,
|
|
1043
|
-
hashCode: id,
|
|
1044
|
-
loaded: true,
|
|
1045
|
-
status: 'Loaded'
|
|
1046
|
-
});
|
|
1047
|
-
observer.complete();
|
|
1048
|
-
this.loadedSources.push(id);
|
|
1049
|
-
};
|
|
1050
|
-
link.onerror = error => {
|
|
1051
|
-
observer.error({
|
|
1052
|
-
src: src,
|
|
1053
|
-
hashCode: id,
|
|
1054
|
-
loaded: true,
|
|
1055
|
-
status: 'Loaded',
|
|
1056
|
-
error: error
|
|
1057
|
-
});
|
|
1058
|
-
observer.complete();
|
|
1059
|
-
};
|
|
1060
|
-
head.appendChild(link);
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
loadScripts(sources, options = {
|
|
1064
|
-
serial: false,
|
|
1065
|
-
sandbox: false
|
|
1066
|
-
}) {
|
|
1067
|
-
if (isEmpty(sources)) {
|
|
1068
|
-
return of(null);
|
|
1069
|
-
}
|
|
1070
|
-
const observables = sources.map(src => {
|
|
1071
|
-
// TODO: 暂时只支持Proxy沙箱
|
|
1072
|
-
if (options.sandbox && window.Proxy) {
|
|
1073
|
-
return this.loadScriptWithSandbox(options.app, src);
|
|
1074
|
-
}
|
|
1075
|
-
else {
|
|
1076
|
-
return this.loadScript(src);
|
|
1077
|
-
}
|
|
1078
|
-
});
|
|
1079
|
-
if (options.serial) {
|
|
1080
|
-
const a = concat(...observables).pipe(map(item => {
|
|
1081
|
-
return of([item]);
|
|
1082
|
-
}), concatAll());
|
|
1083
|
-
return a;
|
|
1084
|
-
}
|
|
1085
|
-
else {
|
|
1086
|
-
return forkJoin(observables).pipe();
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
loadStyles(sources) {
|
|
1090
|
-
if (isEmpty(sources)) {
|
|
1091
|
-
return of(null);
|
|
1092
|
-
}
|
|
1093
|
-
return forkJoin(sources.map(src => {
|
|
1094
|
-
return this.loadStyle(src);
|
|
1095
|
-
}));
|
|
1096
|
-
}
|
|
1097
|
-
loadScriptsAndStyles(scripts = [], styles = [], options) {
|
|
1098
|
-
return forkJoin([this.loadScripts(scripts, options), this.loadStyles(styles)]);
|
|
1099
|
-
}
|
|
1100
|
-
loadAppAssets(app) {
|
|
1101
|
-
if (app.manifest) {
|
|
1102
|
-
return this.loadManifest(`${app.manifest}?t=${new Date().getTime()}`).pipe(switchMap(manifestResult => {
|
|
1103
|
-
const { scripts, styles } = getScriptsAndStylesFullPaths(app, manifestResult);
|
|
1104
|
-
return this.loadScriptsAndStyles(scripts, styles, {
|
|
1105
|
-
app: app.name,
|
|
1106
|
-
sandbox: app.sandbox,
|
|
1107
|
-
serial: app.loadSerial
|
|
1108
|
-
});
|
|
1109
|
-
}));
|
|
1110
|
-
}
|
|
1111
|
-
else {
|
|
1112
|
-
const { scripts, styles } = getScriptsAndStylesFullPaths(app);
|
|
1113
|
-
return this.loadScriptsAndStyles(scripts, styles, {
|
|
1114
|
-
app: app.name,
|
|
1115
|
-
sandbox: app.sandbox,
|
|
1116
|
-
serial: app.loadSerial
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
loadManifest(url) {
|
|
1121
|
-
return this.http.get(url).pipe(map((response) => {
|
|
1122
|
-
return response;
|
|
1123
|
-
}));
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
AssetsLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: AssetsLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1127
|
-
AssetsLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: AssetsLoader, providedIn: 'root' });
|
|
1128
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: AssetsLoader, decorators: [{
|
|
1129
|
-
type: Injectable,
|
|
1130
|
-
args: [{
|
|
1131
|
-
providedIn: 'root'
|
|
1132
|
-
}]
|
|
1133
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
|
|
1134
|
-
|
|
1135
|
-
class PlanetApplicationService {
|
|
1136
|
-
constructor(http, assetsLoader) {
|
|
1137
|
-
this.http = http;
|
|
1138
|
-
this.assetsLoader = assetsLoader;
|
|
1139
|
-
this.apps = [];
|
|
1140
|
-
this.appsMap = {};
|
|
1141
|
-
if (getApplicationService()) {
|
|
1142
|
-
throw new Error('PlanetApplicationService has been injected in the portal, repeated injection is not allowed');
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
register(appOrApps) {
|
|
1146
|
-
const apps = coerceArray(appOrApps);
|
|
1147
|
-
apps.forEach(app => {
|
|
1148
|
-
if (this.appsMap[app.name]) {
|
|
1149
|
-
throw new Error(`${app.name} has be registered.`);
|
|
1150
|
-
}
|
|
1151
|
-
this.apps.push(app);
|
|
1152
|
-
this.appsMap[app.name] = app;
|
|
1153
|
-
});
|
|
1154
|
-
}
|
|
1155
|
-
registerByUrl(url) {
|
|
1156
|
-
const result = this.http.get(`${url}`).pipe(map(apps => {
|
|
1157
|
-
if (apps && Array.isArray(apps)) {
|
|
1158
|
-
this.register(apps);
|
|
1159
|
-
}
|
|
1160
|
-
else {
|
|
1161
|
-
this.register(apps);
|
|
1162
|
-
}
|
|
1163
|
-
}), shareReplay());
|
|
1164
|
-
result.subscribe();
|
|
1165
|
-
return result;
|
|
1166
|
-
}
|
|
1167
|
-
unregister(name) {
|
|
1168
|
-
if (this.appsMap[name]) {
|
|
1169
|
-
delete this.appsMap[name];
|
|
1170
|
-
this.apps = this.apps.filter(app => {
|
|
1171
|
-
return app.name !== name;
|
|
1172
|
-
});
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
getAppsByMatchedUrl(url) {
|
|
1176
|
-
return this.getApps().filter(app => {
|
|
1177
|
-
if (app.routerPathPrefix instanceof RegExp) {
|
|
1178
|
-
return app.routerPathPrefix.test(url);
|
|
1179
|
-
}
|
|
1180
|
-
else {
|
|
1181
|
-
return url.startsWith(app.routerPathPrefix);
|
|
1182
|
-
}
|
|
1183
|
-
});
|
|
1184
|
-
}
|
|
1185
|
-
getAppByName(name) {
|
|
1186
|
-
return this.appsMap[name];
|
|
1187
|
-
}
|
|
1188
|
-
getAppsToPreload(excludeAppNames) {
|
|
1189
|
-
return this.getApps().filter(app => {
|
|
1190
|
-
if (excludeAppNames) {
|
|
1191
|
-
return app.preload && !excludeAppNames.includes(app.name);
|
|
1192
|
-
}
|
|
1193
|
-
else {
|
|
1194
|
-
return app.preload;
|
|
1195
|
-
}
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1198
|
-
getApps() {
|
|
1199
|
-
return this.apps;
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
PlanetApplicationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetApplicationService, deps: [{ token: i1.HttpClient }, { token: AssetsLoader }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1203
|
-
PlanetApplicationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetApplicationService, providedIn: 'root' });
|
|
1204
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetApplicationService, decorators: [{
|
|
1205
|
-
type: Injectable,
|
|
1206
|
-
args: [{
|
|
1207
|
-
providedIn: 'root'
|
|
1208
|
-
}]
|
|
1209
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: AssetsLoader }]; } });
|
|
1210
|
-
|
|
1211
|
-
class PlanetPortalApplication {
|
|
1212
|
-
navigateByUrl(url, extras) {
|
|
1213
|
-
return this.ngZone.run(() => {
|
|
1214
|
-
return this.router.navigateByUrl(url, extras);
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
run(fn) {
|
|
1218
|
-
return this.ngZone.run(() => {
|
|
1219
|
-
return fn();
|
|
1220
|
-
});
|
|
1221
|
-
}
|
|
1222
|
-
tick() {
|
|
1223
|
-
this.applicationRef.tick();
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
const CUSTOM_EVENT_NAME = 'PLANET_GLOBAL_EVENT_DISPATCHER';
|
|
1228
|
-
class GlobalEventDispatcher {
|
|
1229
|
-
addGlobalEventListener() {
|
|
1230
|
-
this.hasAddGlobalEventListener = true;
|
|
1231
|
-
window.addEventListener(CUSTOM_EVENT_NAME, this.globalEventListener);
|
|
1232
|
-
}
|
|
1233
|
-
removeGlobalEventListener() {
|
|
1234
|
-
this.hasAddGlobalEventListener = false;
|
|
1235
|
-
window.removeEventListener(CUSTOM_EVENT_NAME, this.globalEventListener);
|
|
1236
|
-
}
|
|
1237
|
-
constructor(ngZone) {
|
|
1238
|
-
this.ngZone = ngZone;
|
|
1239
|
-
this.subject$ = new Subject();
|
|
1240
|
-
this.hasAddGlobalEventListener = false;
|
|
1241
|
-
this.subscriptionCount = 0;
|
|
1242
|
-
this.globalEventListener = (event) => {
|
|
1243
|
-
this.subject$.next(event.detail);
|
|
1244
|
-
};
|
|
1245
|
-
}
|
|
1246
|
-
dispatch(name, payload) {
|
|
1247
|
-
window.dispatchEvent(new CustomEvent(CUSTOM_EVENT_NAME, {
|
|
1248
|
-
detail: {
|
|
1249
|
-
name: name,
|
|
1250
|
-
payload: payload
|
|
1251
|
-
}
|
|
1252
|
-
}));
|
|
1253
|
-
}
|
|
1254
|
-
register(eventName) {
|
|
1255
|
-
return new Observable(observer => {
|
|
1256
|
-
if (!this.hasAddGlobalEventListener) {
|
|
1257
|
-
this.addGlobalEventListener();
|
|
1258
|
-
}
|
|
1259
|
-
this.subscriptionCount++;
|
|
1260
|
-
const subscription = this.subject$
|
|
1261
|
-
.pipe(filter(event => {
|
|
1262
|
-
return event.name === eventName;
|
|
1263
|
-
}), map(event => {
|
|
1264
|
-
return event.payload;
|
|
1265
|
-
}))
|
|
1266
|
-
.subscribe(payload => {
|
|
1267
|
-
this.ngZone.run(() => {
|
|
1268
|
-
observer.next(payload);
|
|
1269
|
-
});
|
|
1270
|
-
});
|
|
1271
|
-
return () => {
|
|
1272
|
-
this.subscriptionCount--;
|
|
1273
|
-
subscription.unsubscribe();
|
|
1274
|
-
if (!this.subscriptionCount) {
|
|
1275
|
-
this.removeGlobalEventListener();
|
|
1276
|
-
}
|
|
1277
|
-
};
|
|
1278
|
-
});
|
|
1279
|
-
}
|
|
1280
|
-
getSubscriptionCount() {
|
|
1281
|
-
return this.subscriptionCount;
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
GlobalEventDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: GlobalEventDispatcher, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1285
|
-
GlobalEventDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: GlobalEventDispatcher, providedIn: 'root' });
|
|
1286
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: GlobalEventDispatcher, decorators: [{
|
|
1287
|
-
type: Injectable,
|
|
1288
|
-
args: [{
|
|
1289
|
-
providedIn: 'root'
|
|
1290
|
-
}]
|
|
1291
|
-
}], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
|
|
1292
|
-
|
|
1293
|
-
/**
|
|
1294
|
-
* Debug factory for debug module
|
|
1295
|
-
*/
|
|
1296
|
-
let _debugFactory;
|
|
1297
|
-
let _debuggerMap = {};
|
|
1298
|
-
function createDebug(namespace) {
|
|
1299
|
-
const key = `planet:${namespace}`;
|
|
1300
|
-
return function (formatter, ...args) {
|
|
1301
|
-
if (_debugFactory) {
|
|
1302
|
-
let debugDebugger = _debuggerMap[key];
|
|
1303
|
-
if (!debugDebugger) {
|
|
1304
|
-
debugDebugger = _debugFactory(key);
|
|
1305
|
-
_debuggerMap[key] = debugDebugger;
|
|
1306
|
-
}
|
|
1307
|
-
debugDebugger(formatter, args);
|
|
1308
|
-
}
|
|
1309
|
-
};
|
|
1310
|
-
}
|
|
1311
|
-
function setDebugFactory(debug) {
|
|
1312
|
-
if (debug && !isFunction(debug)) {
|
|
1313
|
-
throw new Error('debug factory type is invalid, must be function');
|
|
1314
|
-
}
|
|
1315
|
-
_debugFactory = debug;
|
|
1316
|
-
}
|
|
1317
|
-
function clearDebugFactory() {
|
|
1318
|
-
_debugFactory = undefined;
|
|
1319
|
-
_debuggerMap = {};
|
|
1320
|
-
}
|
|
1321
|
-
function getDebugFactory() {
|
|
1322
|
-
return _debugFactory;
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
const debug = createDebug('app-loader');
|
|
1326
|
-
var ApplicationStatus;
|
|
1327
|
-
(function (ApplicationStatus) {
|
|
1328
|
-
ApplicationStatus[ApplicationStatus["assetsLoading"] = 1] = "assetsLoading";
|
|
1329
|
-
ApplicationStatus[ApplicationStatus["assetsLoaded"] = 2] = "assetsLoaded";
|
|
1330
|
-
ApplicationStatus[ApplicationStatus["bootstrapping"] = 3] = "bootstrapping";
|
|
1331
|
-
ApplicationStatus[ApplicationStatus["bootstrapped"] = 4] = "bootstrapped";
|
|
1332
|
-
ApplicationStatus[ApplicationStatus["active"] = 5] = "active";
|
|
1333
|
-
ApplicationStatus[ApplicationStatus["loadError"] = 10] = "loadError";
|
|
1334
|
-
})(ApplicationStatus || (ApplicationStatus = {}));
|
|
1335
|
-
class PlanetApplicationLoader {
|
|
1336
|
-
get appStatusChange() {
|
|
1337
|
-
return this.appStatusChange$.asObservable();
|
|
1338
|
-
}
|
|
1339
|
-
get appsLoadingStart() {
|
|
1340
|
-
return this.appsLoadingStart$.asObservable();
|
|
1341
|
-
}
|
|
1342
|
-
constructor(assetsLoader, planetApplicationService, ngZone, router, injector, applicationRef) {
|
|
1343
|
-
this.assetsLoader = assetsLoader;
|
|
1344
|
-
this.planetApplicationService = planetApplicationService;
|
|
1345
|
-
this.ngZone = ngZone;
|
|
1346
|
-
this.firstLoad = true;
|
|
1347
|
-
this.inProgressAppAssetsLoads = new Map();
|
|
1348
|
-
this.appsStatus = new Map();
|
|
1349
|
-
this.portalApp = new PlanetPortalApplication();
|
|
1350
|
-
this.routeChange$ = new Subject();
|
|
1351
|
-
this.appStatusChange$ = new Subject();
|
|
1352
|
-
this.appsLoadingStart$ = new Subject();
|
|
1353
|
-
this.loadingDone = false;
|
|
1354
|
-
if (getApplicationLoader()) {
|
|
1355
|
-
throw new Error('PlanetApplicationLoader has been injected in the portal, repeated injection is not allowed');
|
|
1356
|
-
}
|
|
1357
|
-
this.options = {
|
|
1358
|
-
switchMode: SwitchModes.default,
|
|
1359
|
-
errorHandler: (error) => {
|
|
1360
|
-
console.error(error);
|
|
1361
|
-
}
|
|
1362
|
-
};
|
|
1363
|
-
this.portalApp.ngZone = ngZone;
|
|
1364
|
-
this.portalApp.applicationRef = applicationRef;
|
|
1365
|
-
this.portalApp.router = router;
|
|
1366
|
-
this.portalApp.injector = injector;
|
|
1367
|
-
this.portalApp.globalEventDispatcher = injector.get(GlobalEventDispatcher);
|
|
1368
|
-
globalPlanet.portalApplication = this.portalApp;
|
|
1369
|
-
this.setupRouteChange();
|
|
1370
|
-
}
|
|
1371
|
-
setAppStatus(app, status) {
|
|
1372
|
-
this.ngZone.run(() => {
|
|
1373
|
-
const fromStatus = this.appsStatus.get(app);
|
|
1374
|
-
debug(`app(${app.name}) status change: ${fromStatus ? ApplicationStatus[fromStatus] : 'empty'} => ${ApplicationStatus[status]}`);
|
|
1375
|
-
this.appsStatus.set(app, status);
|
|
1376
|
-
this.appStatusChange$.next({
|
|
1377
|
-
app: app,
|
|
1378
|
-
status: status
|
|
1379
|
-
});
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1382
|
-
getAppStatusChange$(app, status = ApplicationStatus.bootstrapped) {
|
|
1383
|
-
return this.appStatusChange.pipe(filter(event => {
|
|
1384
|
-
return event.app === app && event.status === status;
|
|
1385
|
-
}), map(() => {
|
|
1386
|
-
return app;
|
|
1387
|
-
}));
|
|
1388
|
-
}
|
|
1389
|
-
switchModeIsCoexist(app) {
|
|
1390
|
-
if (app && app.switchMode) {
|
|
1391
|
-
return app.switchMode === SwitchModes.coexist;
|
|
1392
|
-
}
|
|
1393
|
-
else {
|
|
1394
|
-
return this.options.switchMode === SwitchModes.coexist;
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
errorHandler(error) {
|
|
1398
|
-
this.ngZone.run(() => {
|
|
1399
|
-
this.options.errorHandler(error);
|
|
1400
|
-
});
|
|
1401
|
-
}
|
|
1402
|
-
setLoadingDone() {
|
|
1403
|
-
this.ngZone.run(() => {
|
|
1404
|
-
this.loadingDone = true;
|
|
1405
|
-
});
|
|
1406
|
-
}
|
|
1407
|
-
getAppNames(apps) {
|
|
1408
|
-
return apps.length === 0
|
|
1409
|
-
? `[]`
|
|
1410
|
-
: apps.map(item => {
|
|
1411
|
-
return item.name;
|
|
1412
|
-
});
|
|
1413
|
-
}
|
|
1414
|
-
setupRouteChange() {
|
|
1415
|
-
this.routeChange$
|
|
1416
|
-
.pipe(distinctUntilChanged((x, y) => {
|
|
1417
|
-
return (x && x.url) === (y && y.url);
|
|
1418
|
-
}),
|
|
1419
|
-
// Using switchMap so we cancel executing loading when a new one comes in
|
|
1420
|
-
switchMap(event => {
|
|
1421
|
-
// Return new observable use of and catchError,
|
|
1422
|
-
// in order to prevent routeChange$ completed which never trigger new route change
|
|
1423
|
-
return of(event).pipe(
|
|
1424
|
-
// unload apps and return should load apps
|
|
1425
|
-
map(() => {
|
|
1426
|
-
debug(`route change, url is: ${event.url}`);
|
|
1427
|
-
this.startRouteChangeEvent = event;
|
|
1428
|
-
const shouldLoadApps = this.planetApplicationService.getAppsByMatchedUrl(event.url);
|
|
1429
|
-
debug(`should load apps: ${this.getAppNames(shouldLoadApps)}`);
|
|
1430
|
-
const shouldUnloadApps = this.getUnloadApps(shouldLoadApps);
|
|
1431
|
-
this.appsLoadingStart$.next({
|
|
1432
|
-
shouldLoadApps,
|
|
1433
|
-
shouldUnloadApps
|
|
1434
|
-
});
|
|
1435
|
-
this.unloadApps(shouldUnloadApps, event);
|
|
1436
|
-
debug(`unload apps: ${this.getAppNames(shouldUnloadApps)}`);
|
|
1437
|
-
return shouldLoadApps;
|
|
1438
|
-
}),
|
|
1439
|
-
// Load app assets (static resources)
|
|
1440
|
-
switchMap(shouldLoadApps => {
|
|
1441
|
-
let hasAppsNeedLoadingAssets = false;
|
|
1442
|
-
const loadApps$ = shouldLoadApps.map(app => {
|
|
1443
|
-
const appStatus = this.appsStatus.get(app);
|
|
1444
|
-
if (!appStatus ||
|
|
1445
|
-
appStatus === ApplicationStatus.assetsLoading ||
|
|
1446
|
-
appStatus === ApplicationStatus.loadError) {
|
|
1447
|
-
debug(`app(${app.name}) status is ${ApplicationStatus[appStatus]}, start load assets`);
|
|
1448
|
-
hasAppsNeedLoadingAssets = true;
|
|
1449
|
-
return this.ngZone.runOutsideAngular(() => {
|
|
1450
|
-
return this.startLoadAppAssets(app);
|
|
1451
|
-
});
|
|
1452
|
-
}
|
|
1453
|
-
else {
|
|
1454
|
-
return of(app);
|
|
1455
|
-
}
|
|
1456
|
-
});
|
|
1457
|
-
if (hasAppsNeedLoadingAssets) {
|
|
1458
|
-
this.loadingDone = false;
|
|
1459
|
-
}
|
|
1460
|
-
return loadApps$.length > 0 ? forkJoin(loadApps$) : of([]);
|
|
1461
|
-
}),
|
|
1462
|
-
// Bootstrap or show apps
|
|
1463
|
-
map(apps => {
|
|
1464
|
-
const apps$ = apps.map(app => {
|
|
1465
|
-
return of(app).pipe(switchMap(app => {
|
|
1466
|
-
const appStatus = this.appsStatus.get(app);
|
|
1467
|
-
if (appStatus === ApplicationStatus.bootstrapped) {
|
|
1468
|
-
debug(`[routeChange] app(${app.name}) status is bootstrapped, show app and active`);
|
|
1469
|
-
this.showApp(app);
|
|
1470
|
-
const appRef = getPlanetApplicationRef(app.name);
|
|
1471
|
-
appRef === null || appRef === void 0 ? void 0 : appRef.navigateByUrl(event.url);
|
|
1472
|
-
this.setAppStatus(app, ApplicationStatus.active);
|
|
1473
|
-
this.setLoadingDone();
|
|
1474
|
-
return of(app);
|
|
1475
|
-
}
|
|
1476
|
-
else if (appStatus === ApplicationStatus.assetsLoaded) {
|
|
1477
|
-
debug(`[routeChange] app(${app.name}) status is assetsLoaded, start bootstrapping`);
|
|
1478
|
-
return this.bootstrapApp(app).pipe(map(() => {
|
|
1479
|
-
debug(`app(${app.name}) bootstrapped success, active it`);
|
|
1480
|
-
this.setAppStatus(app, ApplicationStatus.active);
|
|
1481
|
-
this.setLoadingDone();
|
|
1482
|
-
return app;
|
|
1483
|
-
}));
|
|
1484
|
-
}
|
|
1485
|
-
else if (appStatus === ApplicationStatus.active) {
|
|
1486
|
-
debug(`[routeChange] app(${app.name}) is active, do nothings`);
|
|
1487
|
-
const appRef = getPlanetApplicationRef(app.name);
|
|
1488
|
-
// Backwards compatibility sub app use old version which has not getCurrentRouterStateUrl
|
|
1489
|
-
const currentUrl = (appRef === null || appRef === void 0 ? void 0 : appRef.getCurrentRouterStateUrl)
|
|
1490
|
-
? appRef.getCurrentRouterStateUrl()
|
|
1491
|
-
: '';
|
|
1492
|
-
if (currentUrl !== event.url) {
|
|
1493
|
-
appRef === null || appRef === void 0 ? void 0 : appRef.navigateByUrl(event.url);
|
|
1494
|
-
}
|
|
1495
|
-
return of(app);
|
|
1496
|
-
}
|
|
1497
|
-
else {
|
|
1498
|
-
debug(`[routeChange] app(${app.name}) status is ${ApplicationStatus[appStatus]}`);
|
|
1499
|
-
return this.getAppStatusChange$(app).pipe(take(1), map(() => {
|
|
1500
|
-
debug(`app(${app.name}) status is bootstrapped by subscribe status change, active it`);
|
|
1501
|
-
this.setAppStatus(app, ApplicationStatus.active);
|
|
1502
|
-
this.showApp(app);
|
|
1503
|
-
return app;
|
|
1504
|
-
}));
|
|
1505
|
-
}
|
|
1506
|
-
}));
|
|
1507
|
-
});
|
|
1508
|
-
if (apps$.length > 0) {
|
|
1509
|
-
debug(`start load and active apps: ${this.getAppNames(apps)}`);
|
|
1510
|
-
// 切换到应用后会有闪烁现象,所以使用 setTimeout 后启动应用
|
|
1511
|
-
// example: redirect to app1's dashboard from portal's about page
|
|
1512
|
-
// If app's route has redirect, it doesn't work, it ok just in setTimeout, I don't know why.
|
|
1513
|
-
// TODO:: remove it, it is ok in version Angular 9.x
|
|
1514
|
-
setTimeout(() => {
|
|
1515
|
-
// 此处判断是因为如果静态资源加载完毕还未启动被取消,还是会启动之前的应用,虽然可能性比较小,但是无法排除这种可能性,所以只有当 Event 是最后一个才会启动
|
|
1516
|
-
if (this.startRouteChangeEvent === event) {
|
|
1517
|
-
// runOutsideAngular for fix error: `Expected to not be in Angular Zone, but it is!`
|
|
1518
|
-
this.ngZone.runOutsideAngular(() => {
|
|
1519
|
-
forkJoin(apps$).subscribe(() => {
|
|
1520
|
-
this.setLoadingDone();
|
|
1521
|
-
this.ensurePreloadApps(apps);
|
|
1522
|
-
});
|
|
1523
|
-
});
|
|
1524
|
-
}
|
|
1525
|
-
});
|
|
1526
|
-
}
|
|
1527
|
-
else {
|
|
1528
|
-
debug(`no apps need to be loaded, ensure preload apps`);
|
|
1529
|
-
this.ensurePreloadApps(apps);
|
|
1530
|
-
this.setLoadingDone();
|
|
1531
|
-
}
|
|
1532
|
-
}),
|
|
1533
|
-
// Error handler
|
|
1534
|
-
catchError(error => {
|
|
1535
|
-
debug(`apps loader error: ${error}`);
|
|
1536
|
-
this.errorHandler(error);
|
|
1537
|
-
return [];
|
|
1538
|
-
}));
|
|
1539
|
-
}))
|
|
1540
|
-
.subscribe();
|
|
1541
|
-
}
|
|
1542
|
-
startLoadAppAssets(app) {
|
|
1543
|
-
if (this.inProgressAppAssetsLoads.get(app.name)) {
|
|
1544
|
-
return this.inProgressAppAssetsLoads.get(app.name);
|
|
1545
|
-
}
|
|
1546
|
-
else {
|
|
1547
|
-
const loadApp$ = this.assetsLoader.loadAppAssets(app).pipe(tap(() => {
|
|
1548
|
-
this.inProgressAppAssetsLoads.delete(app.name);
|
|
1549
|
-
this.setAppStatus(app, ApplicationStatus.assetsLoaded);
|
|
1550
|
-
}), map(() => {
|
|
1551
|
-
return app;
|
|
1552
|
-
}), catchError(error => {
|
|
1553
|
-
this.inProgressAppAssetsLoads.delete(app.name);
|
|
1554
|
-
this.setAppStatus(app, ApplicationStatus.loadError);
|
|
1555
|
-
throw error;
|
|
1556
|
-
}), share());
|
|
1557
|
-
this.inProgressAppAssetsLoads.set(app.name, loadApp$);
|
|
1558
|
-
this.setAppStatus(app, ApplicationStatus.assetsLoading);
|
|
1559
|
-
return loadApp$;
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
hideApp(planetApp) {
|
|
1563
|
-
const appRef = getPlanetApplicationRef(planetApp.name);
|
|
1564
|
-
const appRootElement = document.querySelector((appRef === null || appRef === void 0 ? void 0 : appRef.selector) || planetApp.selector);
|
|
1565
|
-
if (appRootElement) {
|
|
1566
|
-
appRootElement.setAttribute('style', 'display:none;');
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
showApp(planetApp) {
|
|
1570
|
-
const appRef = getPlanetApplicationRef(planetApp.name);
|
|
1571
|
-
const appRootElement = document.querySelector((appRef === null || appRef === void 0 ? void 0 : appRef.selector) || planetApp.selector);
|
|
1572
|
-
if (appRootElement) {
|
|
1573
|
-
appRootElement.setAttribute('style', '');
|
|
1574
|
-
}
|
|
1575
|
-
}
|
|
1576
|
-
destroyApp(planetApp) {
|
|
1577
|
-
const appRef = getPlanetApplicationRef(planetApp.name);
|
|
1578
|
-
if (appRef) {
|
|
1579
|
-
appRef.destroy();
|
|
1580
|
-
}
|
|
1581
|
-
const container = getHTMLElement(planetApp.hostParent);
|
|
1582
|
-
const appRootElement = container === null || container === void 0 ? void 0 : container.querySelector((appRef && appRef.selector) || planetApp.selector);
|
|
1583
|
-
if (appRootElement) {
|
|
1584
|
-
container === null || container === void 0 ? void 0 : container.removeChild(appRootElement);
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
bootstrapApp(app, defaultStatus = 'display') {
|
|
1588
|
-
debug(`app(${app.name}) start bootstrapping`);
|
|
1589
|
-
this.setAppStatus(app, ApplicationStatus.bootstrapping);
|
|
1590
|
-
const appRef = getPlanetApplicationRef(app.name);
|
|
1591
|
-
if (appRef && appRef.bootstrap) {
|
|
1592
|
-
const container = getHTMLElement(app.hostParent);
|
|
1593
|
-
let appRootElement;
|
|
1594
|
-
if (container) {
|
|
1595
|
-
appRootElement = container.querySelector(appRef.selector || app.selector);
|
|
1596
|
-
if (!appRootElement) {
|
|
1597
|
-
if (appRef.template) {
|
|
1598
|
-
appRootElement = createElementByTemplate(appRef.template);
|
|
1599
|
-
}
|
|
1600
|
-
else {
|
|
1601
|
-
appRootElement = document.createElement(app.selector);
|
|
1602
|
-
}
|
|
1603
|
-
appRootElement.setAttribute('style', 'display:none;');
|
|
1604
|
-
if (app.hostClass) {
|
|
1605
|
-
appRootElement.classList.add(...coerceArray(app.hostClass));
|
|
1606
|
-
}
|
|
1607
|
-
if (app.stylePrefix) {
|
|
1608
|
-
appRootElement.classList.add(...coerceArray(app.stylePrefix));
|
|
1609
|
-
}
|
|
1610
|
-
container.appendChild(appRootElement);
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
let result = appRef.bootstrap(this.portalApp);
|
|
1614
|
-
// Backwards compatibility promise for bootstrap
|
|
1615
|
-
if (result['then']) {
|
|
1616
|
-
result = from(result);
|
|
1617
|
-
}
|
|
1618
|
-
return result.pipe(tap(() => {
|
|
1619
|
-
debug(`app(${app.name}) bootstrapped success for ${defaultStatus}`);
|
|
1620
|
-
this.setAppStatus(app, ApplicationStatus.bootstrapped);
|
|
1621
|
-
if (defaultStatus === 'display' && appRootElement) {
|
|
1622
|
-
appRootElement.removeAttribute('style');
|
|
1623
|
-
}
|
|
1624
|
-
}), map(() => {
|
|
1625
|
-
return appRef;
|
|
1626
|
-
}));
|
|
1627
|
-
}
|
|
1628
|
-
else {
|
|
1629
|
-
throw new Error(`[${app.name}] not found, make sure that the app has the correct name defined use defineApplication(${app.name}) and runtimeChunk and vendorChunk are set to true, details see https://github.com/worktile/ngx-planet#throw-error-cannot-read-property-call-of-undefined-at-__webpack_require__-bootstrap79`);
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
|
-
getUnloadApps(activeApps) {
|
|
1633
|
-
const unloadApps = [];
|
|
1634
|
-
this.appsStatus.forEach((value, app) => {
|
|
1635
|
-
if (value === ApplicationStatus.active && !activeApps.find(item => item.name === app.name)) {
|
|
1636
|
-
unloadApps.push(app);
|
|
1637
|
-
}
|
|
1638
|
-
});
|
|
1639
|
-
return unloadApps;
|
|
1640
|
-
}
|
|
1641
|
-
unloadApps(shouldUnloadApps, event) {
|
|
1642
|
-
const hideApps = [];
|
|
1643
|
-
const destroyApps = [];
|
|
1644
|
-
shouldUnloadApps.forEach(app => {
|
|
1645
|
-
if (this.switchModeIsCoexist(app)) {
|
|
1646
|
-
debug(`hide app(${app.name}) for coexist mode`);
|
|
1647
|
-
hideApps.push(app);
|
|
1648
|
-
this.hideApp(app);
|
|
1649
|
-
this.setAppStatus(app, ApplicationStatus.bootstrapped);
|
|
1650
|
-
}
|
|
1651
|
-
else {
|
|
1652
|
-
destroyApps.push(app);
|
|
1653
|
-
// 销毁之前先隐藏,否则会出现闪烁,因为 destroy 是延迟执行的
|
|
1654
|
-
// 如果销毁不延迟执行,会出现切换到主应用的时候会有视图卡顿现象
|
|
1655
|
-
this.hideApp(app);
|
|
1656
|
-
this.setAppStatus(app, ApplicationStatus.assetsLoaded);
|
|
1657
|
-
}
|
|
1658
|
-
});
|
|
1659
|
-
if (hideApps.length > 0 || destroyApps.length > 0) {
|
|
1660
|
-
// 从其他应用切换到主应用的时候会有视图卡顿现象,所以先等主应用渲染完毕后再加载其他应用
|
|
1661
|
-
// 此处尝试使用 this.ngZone.onStable.pipe(take(1)) 应用之间的切换会出现闪烁
|
|
1662
|
-
setTimeout(() => {
|
|
1663
|
-
hideApps.forEach(app => {
|
|
1664
|
-
const appRef = getPlanetApplicationRef(app.name);
|
|
1665
|
-
if (appRef) {
|
|
1666
|
-
appRef.navigateByUrl(event.url);
|
|
1667
|
-
}
|
|
1668
|
-
});
|
|
1669
|
-
destroyApps.forEach(app => {
|
|
1670
|
-
debug(`destroy app(${app.name})`);
|
|
1671
|
-
this.destroyApp(app);
|
|
1672
|
-
});
|
|
1673
|
-
});
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
preloadApps(activeApps) {
|
|
1677
|
-
setTimeout(() => {
|
|
1678
|
-
const toPreloadApps = this.planetApplicationService.getAppsToPreload(activeApps ? activeApps.map(item => item.name) : undefined);
|
|
1679
|
-
debug(`start preload apps: ${this.getAppNames(toPreloadApps)}`);
|
|
1680
|
-
const loadApps$ = toPreloadApps.map(preloadApp => {
|
|
1681
|
-
return this.preloadInternal(preloadApp);
|
|
1682
|
-
});
|
|
1683
|
-
forkJoin(loadApps$).subscribe({
|
|
1684
|
-
error: error => {
|
|
1685
|
-
this.errorHandler(error);
|
|
1686
|
-
}
|
|
1687
|
-
});
|
|
1688
|
-
});
|
|
1689
|
-
}
|
|
1690
|
-
ensurePreloadApps(activeApps) {
|
|
1691
|
-
// Start preload apps
|
|
1692
|
-
// Start preload when first time app loaded
|
|
1693
|
-
if (this.firstLoad) {
|
|
1694
|
-
this.preloadApps(activeApps);
|
|
1695
|
-
this.firstLoad = false;
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
setOptions(options) {
|
|
1699
|
-
this.options = Object.assign(Object.assign({}, this.options), options);
|
|
1700
|
-
}
|
|
1701
|
-
/**
|
|
1702
|
-
* reset route by current router
|
|
1703
|
-
*/
|
|
1704
|
-
reroute(event) {
|
|
1705
|
-
this.routeChange$.next(event);
|
|
1706
|
-
}
|
|
1707
|
-
preloadInternal(app, immediate) {
|
|
1708
|
-
const status = this.appsStatus.get(app);
|
|
1709
|
-
if (!status || status === ApplicationStatus.loadError) {
|
|
1710
|
-
debug(`preload app(${app.name}), status is empty, start to load assets`);
|
|
1711
|
-
return this.startLoadAppAssets(app).pipe(switchMap(() => {
|
|
1712
|
-
debug(`preload app(${app.name}), assets loaded, start bootstrap app, immediate: ${!!immediate}`);
|
|
1713
|
-
if (immediate) {
|
|
1714
|
-
return this.bootstrapApp(app, 'hidden');
|
|
1715
|
-
}
|
|
1716
|
-
else {
|
|
1717
|
-
return this.ngZone.runOutsideAngular(() => {
|
|
1718
|
-
return this.bootstrapApp(app, 'hidden');
|
|
1719
|
-
});
|
|
1720
|
-
}
|
|
1721
|
-
}), catchError(error => {
|
|
1722
|
-
this.errorHandler(error);
|
|
1723
|
-
return of(null);
|
|
1724
|
-
}), map(() => {
|
|
1725
|
-
return getPlanetApplicationRef(app.name);
|
|
1726
|
-
}));
|
|
1727
|
-
}
|
|
1728
|
-
else if ([ApplicationStatus.assetsLoading, ApplicationStatus.assetsLoaded, ApplicationStatus.bootstrapping].includes(status)) {
|
|
1729
|
-
debug(`preload app(${app.name}), status is ${ApplicationStatus[status]}, return until bootstrapped`);
|
|
1730
|
-
return this.getAppStatusChange$(app).pipe(take(1), map(() => {
|
|
1731
|
-
return getPlanetApplicationRef(app.name);
|
|
1732
|
-
}));
|
|
1733
|
-
}
|
|
1734
|
-
else {
|
|
1735
|
-
const appRef = getPlanetApplicationRef(app.name);
|
|
1736
|
-
if (!appRef) {
|
|
1737
|
-
throw new Error(`${app.name}'s status is ${ApplicationStatus[status]}, planetApplicationRef is null.`);
|
|
1738
|
-
}
|
|
1739
|
-
return of(appRef);
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
/**
|
|
1743
|
-
* Preload planet application
|
|
1744
|
-
* @param app app
|
|
1745
|
-
* @param immediate bootstrap on stable by default, setting immediate is true, it will bootstrap immediate
|
|
1746
|
-
*/
|
|
1747
|
-
preload(app, immediate) {
|
|
1748
|
-
return this.preloadInternal(app, immediate);
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
PlanetApplicationLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetApplicationLoader, deps: [{ token: AssetsLoader }, { token: PlanetApplicationService }, { token: i0.NgZone }, { token: i3.Router }, { token: i0.Injector }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1752
|
-
PlanetApplicationLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetApplicationLoader, providedIn: 'root' });
|
|
1753
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetApplicationLoader, decorators: [{
|
|
1754
|
-
type: Injectable,
|
|
1755
|
-
args: [{
|
|
1756
|
-
providedIn: 'root'
|
|
1757
|
-
}]
|
|
1758
|
-
}], ctorParameters: function () { return [{ type: AssetsLoader }, { type: PlanetApplicationService }, { type: i0.NgZone }, { type: i3.Router }, { type: i0.Injector }, { type: i0.ApplicationRef }]; } });
|
|
1759
|
-
|
|
1760
|
-
class Planet {
|
|
1761
|
-
get planetApplicationLoader() {
|
|
1762
|
-
return getApplicationLoader();
|
|
1763
|
-
}
|
|
1764
|
-
get planetApplicationService() {
|
|
1765
|
-
return getApplicationService();
|
|
1766
|
-
}
|
|
1767
|
-
get loadingDone() {
|
|
1768
|
-
return this.planetApplicationLoader.loadingDone;
|
|
1769
|
-
}
|
|
1770
|
-
get appStatusChange() {
|
|
1771
|
-
return this.planetApplicationLoader.appStatusChange;
|
|
1772
|
-
}
|
|
1773
|
-
get appsLoadingStart() {
|
|
1774
|
-
return this.planetApplicationLoader.appsLoadingStart;
|
|
1775
|
-
}
|
|
1776
|
-
constructor(injector, router, planetApplications) {
|
|
1777
|
-
this.injector = injector;
|
|
1778
|
-
this.router = router;
|
|
1779
|
-
if (!this.planetApplicationLoader) {
|
|
1780
|
-
setApplicationLoader(this.injector.get(PlanetApplicationLoader));
|
|
1781
|
-
}
|
|
1782
|
-
if (!this.planetApplicationService) {
|
|
1783
|
-
setApplicationService(this.injector.get(PlanetApplicationService));
|
|
1784
|
-
}
|
|
1785
|
-
if (planetApplications) {
|
|
1786
|
-
this.registerApps(planetApplications);
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
setOptions(options) {
|
|
1790
|
-
this.planetApplicationLoader.setOptions(options);
|
|
1791
|
-
if (options.debugFactory) {
|
|
1792
|
-
setDebugFactory(options.debugFactory);
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
setPortalAppData(data) {
|
|
1796
|
-
setPortalApplicationData(data);
|
|
1797
|
-
}
|
|
1798
|
-
registerApp(app) {
|
|
1799
|
-
this.planetApplicationService.register(app);
|
|
1800
|
-
}
|
|
1801
|
-
registerApps(apps) {
|
|
1802
|
-
this.planetApplicationService.register(apps);
|
|
1803
|
-
}
|
|
1804
|
-
unregisterApp(name) {
|
|
1805
|
-
this.planetApplicationService.unregister(name);
|
|
1806
|
-
}
|
|
1807
|
-
getApps() {
|
|
1808
|
-
return this.planetApplicationService.getApps();
|
|
1809
|
-
}
|
|
1810
|
-
start() {
|
|
1811
|
-
this.subscription = this.router.events
|
|
1812
|
-
.pipe(filter(event => {
|
|
1813
|
-
return event instanceof NavigationEnd;
|
|
1814
|
-
}), map(event => {
|
|
1815
|
-
return event.urlAfterRedirects || event.url;
|
|
1816
|
-
}), startWith(location.pathname), distinctUntilChanged())
|
|
1817
|
-
.subscribe((url) => {
|
|
1818
|
-
this.planetApplicationLoader.reroute({
|
|
1819
|
-
url: url
|
|
1820
|
-
});
|
|
1821
|
-
});
|
|
1822
|
-
}
|
|
1823
|
-
stop() {
|
|
1824
|
-
var _a;
|
|
1825
|
-
(_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
Planet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: Planet, deps: [{ token: i0.Injector }, { token: i3.Router }, { token: PLANET_APPLICATIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1829
|
-
Planet.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: Planet, providedIn: 'root' });
|
|
1830
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: Planet, decorators: [{
|
|
1831
|
-
type: Injectable,
|
|
1832
|
-
args: [{
|
|
1833
|
-
providedIn: 'root'
|
|
1834
|
-
}]
|
|
1835
|
-
}], ctorParameters: function () {
|
|
1836
|
-
return [{ type: i0.Injector }, { type: i3.Router }, { type: undefined, decorators: [{
|
|
1837
|
-
type: Inject,
|
|
1838
|
-
args: [PLANET_APPLICATIONS]
|
|
1839
|
-
}, {
|
|
1840
|
-
type: Optional
|
|
1841
|
-
}] }];
|
|
1842
|
-
} });
|
|
1843
|
-
|
|
1844
|
-
class EmptyComponent {
|
|
1845
|
-
}
|
|
1846
|
-
EmptyComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: EmptyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1847
|
-
EmptyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: EmptyComponent, isStandalone: true, selector: "empty-component", ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1848
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: EmptyComponent, decorators: [{
|
|
1849
|
-
type: Component,
|
|
1850
|
-
args: [{
|
|
1851
|
-
// eslint-disable-next-line @angular-eslint/component-selector
|
|
1852
|
-
selector: 'empty-component',
|
|
1853
|
-
template: ``,
|
|
1854
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1855
|
-
standalone: true
|
|
1856
|
-
}]
|
|
1857
|
-
}] });
|
|
1858
|
-
|
|
1859
|
-
class PlanetComponentRef {
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
const componentWrapperClass = 'planet-component-wrapper';
|
|
1863
|
-
function isComponentType(component) {
|
|
1864
|
-
return typeof component === 'function' && component.constructor === Function;
|
|
1865
|
-
}
|
|
1866
|
-
class PlanetComponentLoader {
|
|
1867
|
-
get applicationLoader() {
|
|
1868
|
-
return getApplicationLoader();
|
|
1869
|
-
}
|
|
1870
|
-
get applicationService() {
|
|
1871
|
-
return getApplicationService();
|
|
1872
|
-
}
|
|
1873
|
-
constructor(applicationRef, ngModuleRef, ngZone, document) {
|
|
1874
|
-
this.applicationRef = applicationRef;
|
|
1875
|
-
this.ngModuleRef = ngModuleRef;
|
|
1876
|
-
this.ngZone = ngZone;
|
|
1877
|
-
this.document = document;
|
|
1878
|
-
}
|
|
1879
|
-
getPlantAppRef(name) {
|
|
1880
|
-
if (globalPlanet.apps[name] && globalPlanet.apps[name].appModuleRef) {
|
|
1881
|
-
return of(globalPlanet.apps[name]);
|
|
1882
|
-
}
|
|
1883
|
-
else {
|
|
1884
|
-
const app = this.applicationService.getAppByName(name);
|
|
1885
|
-
return this.applicationLoader.preload(app, true).pipe(map(() => {
|
|
1886
|
-
return globalPlanet.apps[name];
|
|
1887
|
-
}));
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
createInjector(appModuleRef, componentRef) {
|
|
1891
|
-
return Injector.create({
|
|
1892
|
-
providers: [
|
|
1893
|
-
{
|
|
1894
|
-
provide: PlanetComponentRef,
|
|
1895
|
-
useValue: componentRef
|
|
1896
|
-
}
|
|
1897
|
-
],
|
|
1898
|
-
parent: appModuleRef.injector
|
|
1899
|
-
});
|
|
1900
|
-
}
|
|
1901
|
-
getContainerElement(config) {
|
|
1902
|
-
if (!config.container) {
|
|
1903
|
-
throw new Error(`config 'container' cannot be null`);
|
|
1904
|
-
}
|
|
1905
|
-
else {
|
|
1906
|
-
if (config.container.nativeElement) {
|
|
1907
|
-
return config.container.nativeElement;
|
|
1908
|
-
}
|
|
1909
|
-
else {
|
|
1910
|
-
return config.container;
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
insertComponentRootNodeToContainer(container, componentRootNode, hostClass) {
|
|
1915
|
-
const subApp = this.applicationService.getAppByName(this.ngModuleRef.instance.appName);
|
|
1916
|
-
componentRootNode.classList.add(componentWrapperClass);
|
|
1917
|
-
componentRootNode.setAttribute('planet-inline', '');
|
|
1918
|
-
if (hostClass) {
|
|
1919
|
-
componentRootNode.classList.add(hostClass);
|
|
1920
|
-
}
|
|
1921
|
-
if (subApp && subApp.stylePrefix) {
|
|
1922
|
-
componentRootNode.classList.add(subApp.stylePrefix);
|
|
1923
|
-
}
|
|
1924
|
-
// container 是注释则在前方插入,否则在元素内部插入
|
|
1925
|
-
if (container.nodeType === 8) {
|
|
1926
|
-
container.parentElement.insertBefore(componentRootNode, container);
|
|
1927
|
-
}
|
|
1928
|
-
else {
|
|
1929
|
-
container.appendChild(componentRootNode);
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
attachComponent(component, appModuleRef, config) {
|
|
1933
|
-
const plantComponentRef = new PlanetComponentRef();
|
|
1934
|
-
const appRef = this.applicationRef;
|
|
1935
|
-
const injector = this.createInjector(appModuleRef, plantComponentRef);
|
|
1936
|
-
const container = this.getContainerElement(config);
|
|
1937
|
-
const componentRef = createComponent(component, {
|
|
1938
|
-
environmentInjector: appModuleRef.injector,
|
|
1939
|
-
elementInjector: injector
|
|
1940
|
-
});
|
|
1941
|
-
appRef.attachView(componentRef.hostView);
|
|
1942
|
-
const componentRootNode = this.getComponentRootNode(componentRef);
|
|
1943
|
-
this.insertComponentRootNodeToContainer(container, componentRootNode, config.hostClass || config.wrapperClass);
|
|
1944
|
-
if (config.initialState) {
|
|
1945
|
-
Object.assign(componentRef.instance, config.initialState);
|
|
1946
|
-
}
|
|
1947
|
-
plantComponentRef.componentInstance = componentRef.instance;
|
|
1948
|
-
plantComponentRef.componentRef = componentRef;
|
|
1949
|
-
plantComponentRef.hostElement = componentRootNode;
|
|
1950
|
-
plantComponentRef.dispose = () => {
|
|
1951
|
-
if (appRef.viewCount > 0) {
|
|
1952
|
-
appRef.detachView(componentRef.hostView);
|
|
1953
|
-
}
|
|
1954
|
-
componentRef === null || componentRef === void 0 ? void 0 : componentRef.destroy();
|
|
1955
|
-
componentRootNode.remove();
|
|
1956
|
-
};
|
|
1957
|
-
return plantComponentRef;
|
|
1958
|
-
}
|
|
1959
|
-
/** Gets the root HTMLElement for an instantiated component. */
|
|
1960
|
-
getComponentRootNode(componentRef) {
|
|
1961
|
-
return componentRef.hostView.rootNodes[0];
|
|
1962
|
-
}
|
|
1963
|
-
registerComponentFactory(componentOrComponents) {
|
|
1964
|
-
const app = this.ngModuleRef.instance.appName;
|
|
1965
|
-
this.getPlantAppRef(app).subscribe(appRef => {
|
|
1966
|
-
appRef.registerComponentFactory((componentName, config) => {
|
|
1967
|
-
const components = coerceArray(componentOrComponents);
|
|
1968
|
-
const planetComponent = components.find(item => {
|
|
1969
|
-
return isComponentType(item)
|
|
1970
|
-
? reflectComponentType(item).selector.includes(componentName)
|
|
1971
|
-
: item.name === componentName;
|
|
1972
|
-
});
|
|
1973
|
-
if (planetComponent) {
|
|
1974
|
-
return this.ngZone.run(() => {
|
|
1975
|
-
const componentRef = this.attachComponent(isComponentType(planetComponent) ? planetComponent : planetComponent.component, appRef.appModuleRef, config);
|
|
1976
|
-
return componentRef;
|
|
1977
|
-
});
|
|
1978
|
-
}
|
|
1979
|
-
else {
|
|
1980
|
-
throw Error(`unregistered component ${componentName} in app ${app}`);
|
|
1981
|
-
}
|
|
1982
|
-
});
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
register(components) {
|
|
1986
|
-
setTimeout(() => {
|
|
1987
|
-
this.registerComponentFactory(components);
|
|
1988
|
-
});
|
|
1989
|
-
}
|
|
1990
|
-
load(app, componentName, config) {
|
|
1991
|
-
const result = this.getPlantAppRef(app).pipe(delayWhen(appRef => {
|
|
1992
|
-
if (appRef.getComponentFactory()) {
|
|
1993
|
-
return of('');
|
|
1994
|
-
}
|
|
1995
|
-
else {
|
|
1996
|
-
// Because register use 'setTimeout',so timer 20
|
|
1997
|
-
return timer(20);
|
|
1998
|
-
}
|
|
1999
|
-
}), map(appRef => {
|
|
2000
|
-
const componentFactory = appRef.getComponentFactory();
|
|
2001
|
-
if (componentFactory) {
|
|
2002
|
-
return componentFactory(componentName, config);
|
|
2003
|
-
}
|
|
2004
|
-
else {
|
|
2005
|
-
throw new Error(`${app}'s component(${componentName}) is not registered`);
|
|
2006
|
-
}
|
|
2007
|
-
}), shareReplay());
|
|
2008
|
-
result.subscribe();
|
|
2009
|
-
return result;
|
|
2010
|
-
}
|
|
2011
|
-
}
|
|
2012
|
-
PlanetComponentLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetComponentLoader, deps: [{ token: i0.ApplicationRef }, { token: i0.NgModuleRef }, { token: i0.NgZone }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2013
|
-
PlanetComponentLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetComponentLoader, providedIn: 'root' });
|
|
2014
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetComponentLoader, decorators: [{
|
|
2015
|
-
type: Injectable,
|
|
2016
|
-
args: [{
|
|
2017
|
-
providedIn: 'root'
|
|
2018
|
-
}]
|
|
2019
|
-
}], ctorParameters: function () {
|
|
2020
|
-
return [{ type: i0.ApplicationRef }, { type: i0.NgModuleRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
|
|
2021
|
-
type: Inject,
|
|
2022
|
-
args: [DOCUMENT]
|
|
2023
|
-
}] }];
|
|
2024
|
-
} });
|
|
2025
|
-
|
|
2026
|
-
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
2027
|
-
class PlanetComponentOutlet {
|
|
2028
|
-
constructor(elementRef, planetComponentLoader, ngZone) {
|
|
2029
|
-
this.elementRef = elementRef;
|
|
2030
|
-
this.planetComponentLoader = planetComponentLoader;
|
|
2031
|
-
this.ngZone = ngZone;
|
|
2032
|
-
this.planetComponentLoaded = new EventEmitter();
|
|
2033
|
-
this.destroyed$ = new Subject();
|
|
2034
|
-
}
|
|
2035
|
-
ngOnChanges(changes) {
|
|
2036
|
-
if (this.planetComponentOutlet && !changes.planetComponentOutlet.isFirstChange()) {
|
|
2037
|
-
this.loadComponent();
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
ngAfterViewInit() {
|
|
2041
|
-
this.loadComponent();
|
|
2042
|
-
}
|
|
2043
|
-
loadComponent() {
|
|
2044
|
-
this.clear();
|
|
2045
|
-
if (this.planetComponentOutlet && this.planetComponentOutletApp) {
|
|
2046
|
-
this.planetComponentLoader
|
|
2047
|
-
.load(this.planetComponentOutletApp, this.planetComponentOutlet, {
|
|
2048
|
-
container: this.elementRef.nativeElement,
|
|
2049
|
-
initialState: this.planetComponentOutletInitialState
|
|
2050
|
-
})
|
|
2051
|
-
.pipe(takeUntil(this.destroyed$))
|
|
2052
|
-
.subscribe(componentRef => {
|
|
2053
|
-
this.componentRef = componentRef;
|
|
2054
|
-
this.ngZone.run(() => {
|
|
2055
|
-
Promise.resolve().then(() => {
|
|
2056
|
-
this.planetComponentLoaded.emit(this.componentRef);
|
|
2057
|
-
});
|
|
2058
|
-
});
|
|
2059
|
-
});
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2062
|
-
ngOnDestroy() {
|
|
2063
|
-
this.clear();
|
|
2064
|
-
this.destroyed$.complete();
|
|
2065
|
-
}
|
|
2066
|
-
clear() {
|
|
2067
|
-
var _a;
|
|
2068
|
-
(_a = this.componentRef) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
2069
|
-
this.destroyed$.next();
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
PlanetComponentOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetComponentOutlet, deps: [{ token: i0.ElementRef }, { token: PlanetComponentLoader }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2073
|
-
PlanetComponentOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: PlanetComponentOutlet, isStandalone: true, selector: "[planetComponentOutlet]", inputs: { planetComponentOutlet: "planetComponentOutlet", planetComponentOutletApp: "planetComponentOutletApp", planetComponentOutletInitialState: "planetComponentOutletInitialState" }, outputs: { planetComponentLoaded: "planetComponentLoaded" }, usesOnChanges: true, ngImport: i0 });
|
|
2074
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlanetComponentOutlet, decorators: [{
|
|
2075
|
-
type: Directive,
|
|
2076
|
-
args: [{
|
|
2077
|
-
selector: '[planetComponentOutlet]',
|
|
2078
|
-
standalone: true
|
|
2079
|
-
}]
|
|
2080
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: PlanetComponentLoader }, { type: i0.NgZone }]; }, propDecorators: { planetComponentOutlet: [{
|
|
2081
|
-
type: Input
|
|
2082
|
-
}], planetComponentOutletApp: [{
|
|
2083
|
-
type: Input
|
|
2084
|
-
}], planetComponentOutletInitialState: [{
|
|
2085
|
-
type: Input
|
|
2086
|
-
}], planetComponentLoaded: [{
|
|
2087
|
-
type: Output
|
|
2088
|
-
}] } });
|
|
2089
|
-
|
|
2090
|
-
class RouteRedirect {
|
|
2091
|
-
constructor(redirectTo) {
|
|
2092
|
-
this.activatedRoute = inject(ActivatedRoute);
|
|
2093
|
-
this.router = inject(Router);
|
|
2094
|
-
const finalRedirectTo = redirectTo || this.activatedRoute.snapshot.data.redirectTo;
|
|
2095
|
-
if (finalRedirectTo) {
|
|
2096
|
-
const activatedRouteUrl = this.activatedRoute.pathFromRoot
|
|
2097
|
-
.filter(route => {
|
|
2098
|
-
var _a;
|
|
2099
|
-
return ((_a = route.snapshot.url) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
2100
|
-
})
|
|
2101
|
-
.map(route => {
|
|
2102
|
-
return route.snapshot.url.join('/');
|
|
2103
|
-
})
|
|
2104
|
-
.join('/');
|
|
2105
|
-
if (this.router.isActive(activatedRouteUrl, {
|
|
2106
|
-
matrixParams: 'exact',
|
|
2107
|
-
paths: 'exact',
|
|
2108
|
-
queryParams: 'exact',
|
|
2109
|
-
fragment: 'exact'
|
|
2110
|
-
})) {
|
|
2111
|
-
this.router.navigate([`${finalRedirectTo}`],
|
|
2112
|
-
// By replacing the current URL in the history, we keep the Browser's Back
|
|
2113
|
-
// Button behavior in tact. This will allow the user to easily navigate back
|
|
2114
|
-
// to the previous URL without getting caught in a redirect.
|
|
2115
|
-
{
|
|
2116
|
-
replaceUrl: true,
|
|
2117
|
-
relativeTo: this.activatedRoute
|
|
2118
|
-
});
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
function routeRedirect(redirectTo) {
|
|
2124
|
-
return new RouteRedirect(redirectTo);
|
|
2125
|
-
}
|
|
2126
|
-
class RedirectToRouteComponent {
|
|
2127
|
-
constructor() {
|
|
2128
|
-
this.routeRedirect = routeRedirect();
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
RedirectToRouteComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: RedirectToRouteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2132
|
-
RedirectToRouteComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: RedirectToRouteComponent, isStandalone: true, selector: "planet-redirect-to-route", ngImport: i0, template: '', isInline: true });
|
|
2133
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: RedirectToRouteComponent, decorators: [{
|
|
2134
|
-
type: Component,
|
|
2135
|
-
args: [{
|
|
2136
|
-
selector: 'planet-redirect-to-route',
|
|
2137
|
-
template: '',
|
|
2138
|
-
standalone: true
|
|
2139
|
-
}]
|
|
2140
|
-
}] });
|
|
2141
|
-
function redirectToRoute(redirectTo) {
|
|
2142
|
-
return {
|
|
2143
|
-
path: '',
|
|
2144
|
-
component: RedirectToRouteComponent,
|
|
2145
|
-
data: {
|
|
2146
|
-
redirectTo: redirectTo
|
|
2147
|
-
}
|
|
2148
|
-
};
|
|
2149
|
-
}
|
|
2150
|
-
|
|
2151
|
-
class NgxPlanetModule {
|
|
2152
|
-
static forRoot(apps) {
|
|
2153
|
-
return {
|
|
2154
|
-
ngModule: NgxPlanetModule,
|
|
2155
|
-
providers: [
|
|
2156
|
-
{
|
|
2157
|
-
provide: PLANET_APPLICATIONS,
|
|
2158
|
-
useValue: apps
|
|
2159
|
-
}
|
|
2160
|
-
]
|
|
2161
|
-
};
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
NgxPlanetModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgxPlanetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2165
|
-
NgxPlanetModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.5", ngImport: i0, type: NgxPlanetModule, imports: [HttpClientModule, PlanetComponentOutlet, EmptyComponent, RedirectToRouteComponent], exports: [HttpClientModule, EmptyComponent, PlanetComponentOutlet] });
|
|
2166
|
-
NgxPlanetModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgxPlanetModule, imports: [HttpClientModule, EmptyComponent, RedirectToRouteComponent, HttpClientModule] });
|
|
2167
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: NgxPlanetModule, decorators: [{
|
|
2168
|
-
type: NgModule,
|
|
2169
|
-
args: [{
|
|
2170
|
-
declarations: [],
|
|
2171
|
-
imports: [HttpClientModule, PlanetComponentOutlet, EmptyComponent, RedirectToRouteComponent],
|
|
2172
|
-
providers: [],
|
|
2173
|
-
exports: [HttpClientModule, EmptyComponent, PlanetComponentOutlet]
|
|
2174
|
-
}]
|
|
2175
|
-
}] });
|
|
2176
|
-
|
|
2177
|
-
class PlantComponentConfig {
|
|
2178
|
-
constructor() {
|
|
2179
|
-
/** Data being injected into the child component. */
|
|
2180
|
-
this.initialState = null;
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
|
|
2184
|
-
/*
|
|
2185
|
-
* Public API Surface of core
|
|
2186
|
-
*/
|
|
2187
|
-
|
|
2188
|
-
/**
|
|
2189
|
-
* Generated bundle index. Do not edit.
|
|
2190
|
-
*/
|
|
2191
|
-
|
|
2192
|
-
export { ApplicationStatus, AssetsLoader, EmptyComponent, GlobalEventDispatcher, NgxPlanetModule, PLANET_APPLICATIONS, Planet, PlanetApplicationLoader, PlanetApplicationRef, PlanetApplicationService, PlanetComponentLoader, PlanetComponentOutlet, PlanetComponentRef, PlanetPortalApplication, PlantComponentConfig, RedirectToRouteComponent, SwitchModes, defineApplication, getPlanetApplicationRef, getPortalApplicationData, redirectToRoute, routeRedirect };
|
|
2193
|
-
//# sourceMappingURL=worktile-planet.mjs.map
|